type Field … var _minTimeInt64 … var _maxTimeInt64 … // Skip constructs a no-op field, which is often useful when handling invalid // inputs in other Field constructors. func Skip() Field { … } // nilField returns a field which will marshal explicitly as nil. See motivation // in https://github.com/uber-go/zap/issues/753 . If we ever make breaking // changes and add zapcore.NilType and zapcore.ObjectEncoder.AddNil, the // implementation here should be changed to reflect that. func nilField(key string) Field { … } // Binary constructs a field that carries an opaque binary blob. // // Binary data is serialized in an encoding-appropriate format. For example, // zap's JSON encoder base64-encodes binary blobs. To log UTF-8 encoded text, // use ByteString. func Binary(key string, val []byte) Field { … } // Bool constructs a field that carries a bool. func Bool(key string, val bool) Field { … } // Boolp constructs a field that carries a *bool. The returned Field will safely // and explicitly represent `nil` when appropriate. func Boolp(key string, val *bool) Field { … } // ByteString constructs a field that carries UTF-8 encoded text as a []byte. // To log opaque binary blobs (which aren't necessarily valid UTF-8), use // Binary. func ByteString(key string, val []byte) Field { … } // Complex128 constructs a field that carries a complex number. Unlike most // numeric fields, this costs an allocation (to convert the complex128 to // interface{}). func Complex128(key string, val complex128) Field { … } // Complex128p constructs a field that carries a *complex128. The returned Field will safely // and explicitly represent `nil` when appropriate. func Complex128p(key string, val *complex128) Field { … } // Complex64 constructs a field that carries a complex number. Unlike most // numeric fields, this costs an allocation (to convert the complex64 to // interface{}). func Complex64(key string, val complex64) Field { … } // Complex64p constructs a field that carries a *complex64. The returned Field will safely // and explicitly represent `nil` when appropriate. func Complex64p(key string, val *complex64) Field { … } // Float64 constructs a field that carries a float64. The way the // floating-point value is represented is encoder-dependent, so marshaling is // necessarily lazy. func Float64(key string, val float64) Field { … } // Float64p constructs a field that carries a *float64. The returned Field will safely // and explicitly represent `nil` when appropriate. func Float64p(key string, val *float64) Field { … } // Float32 constructs a field that carries a float32. The way the // floating-point value is represented is encoder-dependent, so marshaling is // necessarily lazy. func Float32(key string, val float32) Field { … } // Float32p constructs a field that carries a *float32. The returned Field will safely // and explicitly represent `nil` when appropriate. func Float32p(key string, val *float32) Field { … } // Int constructs a field with the given key and value. func Int(key string, val int) Field { … } // Intp constructs a field that carries a *int. The returned Field will safely // and explicitly represent `nil` when appropriate. func Intp(key string, val *int) Field { … } // Int64 constructs a field with the given key and value. func Int64(key string, val int64) Field { … } // Int64p constructs a field that carries a *int64. The returned Field will safely // and explicitly represent `nil` when appropriate. func Int64p(key string, val *int64) Field { … } // Int32 constructs a field with the given key and value. func Int32(key string, val int32) Field { … } // Int32p constructs a field that carries a *int32. The returned Field will safely // and explicitly represent `nil` when appropriate. func Int32p(key string, val *int32) Field { … } // Int16 constructs a field with the given key and value. func Int16(key string, val int16) Field { … } // Int16p constructs a field that carries a *int16. The returned Field will safely // and explicitly represent `nil` when appropriate. func Int16p(key string, val *int16) Field { … } // Int8 constructs a field with the given key and value. func Int8(key string, val int8) Field { … } // Int8p constructs a field that carries a *int8. The returned Field will safely // and explicitly represent `nil` when appropriate. func Int8p(key string, val *int8) Field { … } // String constructs a field with the given key and value. func String(key string, val string) Field { … } // Stringp constructs a field that carries a *string. The returned Field will safely // and explicitly represent `nil` when appropriate. func Stringp(key string, val *string) Field { … } // Uint constructs a field with the given key and value. func Uint(key string, val uint) Field { … } // Uintp constructs a field that carries a *uint. The returned Field will safely // and explicitly represent `nil` when appropriate. func Uintp(key string, val *uint) Field { … } // Uint64 constructs a field with the given key and value. func Uint64(key string, val uint64) Field { … } // Uint64p constructs a field that carries a *uint64. The returned Field will safely // and explicitly represent `nil` when appropriate. func Uint64p(key string, val *uint64) Field { … } // Uint32 constructs a field with the given key and value. func Uint32(key string, val uint32) Field { … } // Uint32p constructs a field that carries a *uint32. The returned Field will safely // and explicitly represent `nil` when appropriate. func Uint32p(key string, val *uint32) Field { … } // Uint16 constructs a field with the given key and value. func Uint16(key string, val uint16) Field { … } // Uint16p constructs a field that carries a *uint16. The returned Field will safely // and explicitly represent `nil` when appropriate. func Uint16p(key string, val *uint16) Field { … } // Uint8 constructs a field with the given key and value. func Uint8(key string, val uint8) Field { … } // Uint8p constructs a field that carries a *uint8. The returned Field will safely // and explicitly represent `nil` when appropriate. func Uint8p(key string, val *uint8) Field { … } // Uintptr constructs a field with the given key and value. func Uintptr(key string, val uintptr) Field { … } // Uintptrp constructs a field that carries a *uintptr. The returned Field will safely // and explicitly represent `nil` when appropriate. func Uintptrp(key string, val *uintptr) Field { … } // 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 fails (e.g., trying to serialize a map[int]string to JSON), Reflect // includes the error message in the final log output. func Reflect(key string, val interface{ … } // Namespace creates a named, isolated scope within the logger's context. All // subsequent fields will be added to the new namespace. // // This helps prevent key collisions when injecting loggers into sub-components // or third-party libraries. func Namespace(key string) Field { … } // Stringer constructs a field with the given key and the output of the value's // String method. The Stringer's String method is called lazily. func Stringer(key string, val fmt.Stringer) Field { … } // Time constructs a Field with the given key and value. The encoder // controls how the time is serialized. func Time(key string, val time.Time) Field { … } // Timep constructs a field that carries a *time.Time. The returned Field will safely // and explicitly represent `nil` when appropriate. func Timep(key string, val *time.Time) Field { … } // Stack constructs a field that stores a stacktrace of the current goroutine // under provided key. Keep in mind that taking a stacktrace is eager and // expensive (relatively speaking); this function both makes an allocation and // takes about two microseconds. func Stack(key string) Field { … } // StackSkip constructs a field similarly to Stack, but also skips the given // number of frames from the top of the stacktrace. func StackSkip(key string, skip int) Field { … } // Duration constructs a field with the given key and value. The encoder // controls how the duration is serialized. func Duration(key string, val time.Duration) Field { … } // Durationp constructs a field that carries a *time.Duration. The returned Field will safely // and explicitly represent `nil` when appropriate. func Durationp(key string, val *time.Duration) Field { … } // Object constructs a field with the given key and ObjectMarshaler. It // provides a flexible, but still type-safe and efficient, way to add map- or // struct-like user-defined types to the logging context. The struct's // MarshalLogObject method is called lazily. func Object(key string, val zapcore.ObjectMarshaler) Field { … } // Inline constructs a Field that is similar to Object, but it // will add the elements of the provided ObjectMarshaler to the // current namespace. func Inline(val zapcore.ObjectMarshaler) Field { … } // Dict constructs a field containing the provided key-value pairs. // It acts similar to [Object], but with the fields specified as arguments. func Dict(key string, val ...Field) Field { … } // We need a function with the signature (string, T) for zap.Any. func dictField(key string, val []Field) Field { … } type dictObject … func (d dictObject) MarshalLogObject(enc zapcore.ObjectEncoder) error { … } type anyFieldC … func (f anyFieldC[T]) Any(key string, val any) Field { … } // Any takes a key and an arbitrary value and chooses the best way to represent // them as a field, falling back to a reflection-based approach only if // necessary. // // Since byte/uint8 and rune/int32 are aliases, Any can't differentiate between // them. To minimize surprises, []byte values are treated as binary blobs, byte // values are treated as uint8, and runes are always treated as integers. func Any(key string, value interface{ … }