Use zap.Any for handling interface{} -> zap.Field conversion

zap.Any falls back to zap.Reflect, but is better for this case, because
it first checks for the types that zap handles specially.  For example,
time.Duration, or error, which zap.Reflect will just treat as untyped
int64 or struct objects, but zap.Any is able to detect these types and
print them properly.
pull/1041/head
Nicholas Wilson 2019-07-04 10:21:32 +01:00 committed by Jack Christensen
parent 4a2209a1b4
commit aafa04c156
1 changed files with 1 additions and 1 deletions

View File

@ -21,7 +21,7 @@ func (pl *Logger) Log(ctx context.Context, level pgx.LogLevel, msg string, data
fields := make([]zapcore.Field, len(data))
i := 0
for k, v := range data {
fields[i] = zap.Reflect(k, v)
fields[i] = zap.Any(k, v)
i++
}