2
0

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.
This commit is contained in:
Nicholas Wilson
2019-07-04 10:21:32 +01:00
parent 7c5d801f05
commit 8ba5485db6
+1 -1
View File
@@ -19,7 +19,7 @@ func (pl *Logger) Log(level pgx.LogLevel, msg string, data map[string]interface{
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++
}