Skip to content

Commit

Permalink
app/log: fix logfmt bug (#488)
Browse files Browse the repository at this point in the history
This fixes a panic when using `logfmt` formatter and logging slices (which is doesn't support) by convertng any non-standard values to string first.

category: bug
ticket: none
feature_set: stable
  • Loading branch information
corverroos committed May 6, 2022
1 parent 9a14e2e commit 56272ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/z/zapfield.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ func F64(key string, val float64) Field {
}
}

// Any returns a wrapped zap any field.
// Any returns a wrapped zap string field with the string version of value.
// Note we are not using zap.Any since logfmt formatter doesn't support it.
func Any(key string, val interface{}) Field {
return func(add func(zap.Field)) {
add(zap.Any(key, val))
add(zap.String(key, fmt.Sprint(val)))
}
}

Expand Down

0 comments on commit 56272ca

Please sign in to comment.