Skip to content

Commit

Permalink
chore: Replace fmt.Printf calls with warning logs (#1305)
Browse files Browse the repository at this point in the history
Co-authored-by: wwared <[email protected]>
  • Loading branch information
wwared and wwared authored Nov 15, 2024
1 parent c975bac commit 525615c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion frontend/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"reflect"
"strconv"
"strings"

"github.com/consensys/gnark/logger"
)

// Schema represents the structure of a gnark circuit (/ witness)
Expand Down Expand Up @@ -322,7 +324,8 @@ func parse(r []Field, input interface{}, target reflect.Type, parentFullName, pa
if tValue.Kind() == reflect.Slice || tValue.Kind() == reflect.Array {
if tValue.Len() == 0 {
if reflect.SliceOf(target) == tValue.Type() {
fmt.Printf("ignoring uninitialized slice: %s %s\n", parentGoName, reflect.SliceOf(target).String())
log := logger.Logger()
log.Warn().Str("slice name", parentGoName).Str("slice type", reflect.SliceOf(target).String()).Msg("ignoring uninitialized slice")
}
return r, nil
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/schema/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/consensys/gnark/frontend/schema/internal/reflectwalk"
"github.com/consensys/gnark/logger"
)

// Walk walks through the provided object and stops when it encounters objects of type tLeaf
Expand Down Expand Up @@ -82,7 +83,8 @@ func (w *walker) Pointer(value reflect.Value) error {
func (w *walker) Slice(value reflect.Value) error {
if value.Type() == w.targetSlice {
if value.Len() == 0 {
fmt.Printf("ignoring uninitialized slice: %s %s\n", w.name(), reflect.SliceOf(w.target).String())
log := logger.Logger()
log.Warn().Str("slice name", w.name()).Str("slice type", reflect.SliceOf(w.target).String()).Msg("ignoring uninitialized slice")
return nil
}
return w.handleLeaves(value)
Expand Down

0 comments on commit 525615c

Please sign in to comment.