Skip to content

Commit

Permalink
better comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Pastro committed Oct 6, 2022
1 parent fe2a182 commit 3d92058
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sugar.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,14 @@ func (s *SugaredLogger) sweetenFields(args []interface{}) []Field {
continue
}

// If it is an error.
// If it is an error, consume it and move on.
if err, ok := args[i].(error); ok {
fields = append(fields, Error(err))
i++
continue
}

// If it is not a singular error, make sure this element isn't a dangling key.
// Make sure this element isn't a dangling key.
if i == len(args)-1 {
s.base.Error(_oddNumberErrMsg, Any("ignored", args[i]))
break
Expand Down
4 changes: 2 additions & 2 deletions sugar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ func TestSugarStructuredLogging(t *testing.T) {
// Common to all test cases.
err := errors.New("qux")
context := []interface{}{"foo", "bar"}
extra := []interface{}{"baz", false, err}
expectedFields := []Field{String("foo", "bar"), Bool("baz", false), Error(err)}
extra := []interface{}{err, "baz", false}
expectedFields := []Field{String("foo", "bar"), Error(err), Bool("baz", false)}

for _, tt := range tests {
withSugar(t, DebugLevel, nil, func(logger *SugaredLogger, logs *observer.ObservedLogs) {
Expand Down

0 comments on commit 3d92058

Please sign in to comment.