MCPcopy
hub / github.com/uber-go/zap / Reflect

Function Reflect

field.go:326–328  ·  view source on GitHub ↗

Reflect constructs a field with the given key and an arbitrary object. It uses an encoding-appropriate, reflection-based function to lazily serialize nearly any object into the logging context, but it's relatively slow and allocation-heavy. Outside tests, Any is always a better choice. If encoding

(key string, val interface{})

Source from the content-addressed store, hash-verified

324// If encoding fails (e.g., trying to serialize a map[int]string to JSON), Reflect
325// includes the error message in the final log output.
326func Reflect(key string, val interface{}) Field {
327 return Field{Key: key, Type: zapcore.ReflectType, Interface: val}
328}
329
330// Namespace creates a named, isolated scope within the logger's context. All
331// subsequent fields will be added to the new namespace.

Callers 5

TestJSONEncodeEntryFunction · 0.92
TestFieldConstructorsFunction · 0.85
BenchmarkReflectFieldFunction · 0.85
BenchmarkBoolsReflectFunction · 0.85
nilFieldFunction · 0.85

Calls

no outgoing calls

Tested by 4

TestJSONEncodeEntryFunction · 0.74
TestFieldConstructorsFunction · 0.68
BenchmarkReflectFieldFunction · 0.68
BenchmarkBoolsReflectFunction · 0.68