package zap
import (
)
type Field = zapcore.Field
var (
_minTimeInt64 = time.Unix(0, math.MinInt64)
_maxTimeInt64 = time.Unix(0, math.MaxInt64)
)
func () Field {
return Field{Type: zapcore.SkipType}
}
func ( string) Field { return Reflect(, nil) }
func ( string, []byte) Field {
return Field{Key: , Type: zapcore.BinaryType, Interface: }
}
func ( string, bool) Field {
var int64
if {
= 1
}
return Field{Key: , Type: zapcore.BoolType, Integer: }
}
func ( string, *bool) Field {
if == nil {
return nilField()
}
return Bool(, *)
}
func ( string, []byte) Field {
return Field{Key: , Type: zapcore.ByteStringType, Interface: }
}
func ( string, complex128) Field {
return Field{Key: , Type: zapcore.Complex128Type, Interface: }
}
func ( string, *complex128) Field {
if == nil {
return nilField()
}
return Complex128(, *)
}
func ( string, complex64) Field {
return Field{Key: , Type: zapcore.Complex64Type, Interface: }
}
func ( string, *complex64) Field {
if == nil {
return nilField()
}
return Complex64(, *)
}
func ( string, float64) Field {
return Field{Key: , Type: zapcore.Float64Type, Integer: int64(math.Float64bits())}
}
func ( string, *float64) Field {
if == nil {
return nilField()
}
return Float64(, *)
}
func ( string, float32) Field {
return Field{Key: , Type: zapcore.Float32Type, Integer: int64(math.Float32bits())}
}
func ( string, *float32) Field {
if == nil {
return nilField()
}
return Float32(, *)
}
func ( string, int) Field {
return Int64(, int64())
}
func ( string, *int) Field {
if == nil {
return nilField()
}
return Int(, *)
}
func ( string, int64) Field {
return Field{Key: , Type: zapcore.Int64Type, Integer: }
}
func ( string, *int64) Field {
if == nil {
return nilField()
}
return Int64(, *)
}
func ( string, int32) Field {
return Field{Key: , Type: zapcore.Int32Type, Integer: int64()}
}
func ( string, *int32) Field {
if == nil {
return nilField()
}
return Int32(, *)
}
func ( string, int16) Field {
return Field{Key: , Type: zapcore.Int16Type, Integer: int64()}
}
func ( string, *int16) Field {
if == nil {
return nilField()
}
return Int16(, *)
}
func ( string, int8) Field {
return Field{Key: , Type: zapcore.Int8Type, Integer: int64()}
}
func ( string, *int8) Field {
if == nil {
return nilField()
}
return Int8(, *)
}
func ( string, string) Field {
return Field{Key: , Type: zapcore.StringType, String: }
}
func ( string, *string) Field {
if == nil {
return nilField()
}
return String(, *)
}
func ( string, uint) Field {
return Uint64(, uint64())
}
func ( string, *uint) Field {
if == nil {
return nilField()
}
return Uint(, *)
}
func ( string, uint64) Field {
return Field{Key: , Type: zapcore.Uint64Type, Integer: int64()}
}
func ( string, *uint64) Field {
if == nil {
return nilField()
}
return Uint64(, *)
}
func ( string, uint32) Field {
return Field{Key: , Type: zapcore.Uint32Type, Integer: int64()}
}
func ( string, *uint32) Field {
if == nil {
return nilField()
}
return Uint32(, *)
}
func ( string, uint16) Field {
return Field{Key: , Type: zapcore.Uint16Type, Integer: int64()}
}
func ( string, *uint16) Field {
if == nil {
return nilField()
}
return Uint16(, *)
}
func ( string, uint8) Field {
return Field{Key: , Type: zapcore.Uint8Type, Integer: int64()}
}
func ( string, *uint8) Field {
if == nil {
return nilField()
}
return Uint8(, *)
}
func ( string, uintptr) Field {
return Field{Key: , Type: zapcore.UintptrType, Integer: int64()}
}
func ( string, *uintptr) Field {
if == nil {
return nilField()
}
return Uintptr(, *)
}
func ( string, interface{}) Field {
return Field{Key: , Type: zapcore.ReflectType, Interface: }
}
func ( string) Field {
return Field{Key: , Type: zapcore.NamespaceType}
}
func ( string, fmt.Stringer) Field {
return Field{Key: , Type: zapcore.StringerType, Interface: }
}
func ( string, time.Time) Field {
if .Before(_minTimeInt64) || .After(_maxTimeInt64) {
return Field{Key: , Type: zapcore.TimeFullType, Interface: }
}
return Field{Key: , Type: zapcore.TimeType, Integer: .UnixNano(), Interface: .Location()}
}
func ( string, *time.Time) Field {
if == nil {
return nilField()
}
return Time(, *)
}
func ( string) Field {
return StackSkip(, 1)
}
func ( string, int) Field {
return String(, stacktrace.Take(+1))
}
func ( string, time.Duration) Field {
return Field{Key: , Type: zapcore.DurationType, Integer: int64()}
}
func ( string, *time.Duration) Field {
if == nil {
return nilField()
}
return Duration(, *)
}
func ( string, zapcore.ObjectMarshaler) Field {
return Field{Key: , Type: zapcore.ObjectMarshalerType, Interface: }
}
func ( zapcore.ObjectMarshaler) Field {
return zapcore.Field{
Type: zapcore.InlineMarshalerType,
Interface: ,
}
}
func ( string, ...Field) Field {
return dictField(, )
}
func ( string, []Field) Field {
return Object(, dictObject())
}
type dictObject []Field
func ( dictObject) ( zapcore.ObjectEncoder) error {
for , := range {
.AddTo()
}
return nil
}
type anyFieldC[ any] func(string, ) Field
func ( anyFieldC[]) ( string, any) Field {
, := .()
return (, )
}
func ( string, interface{}) Field {
var interface{ (string, any) Field }
switch .(type) {
case zapcore.ObjectMarshaler:
= anyFieldC[zapcore.ObjectMarshaler](Object)
case zapcore.ArrayMarshaler:
= anyFieldC[zapcore.ArrayMarshaler](Array)
case []Field:
= anyFieldC[[]Field](dictField)
case bool:
= anyFieldC[bool](Bool)
case *bool:
= anyFieldC[*bool](Boolp)
case []bool:
= anyFieldC[[]bool](Bools)
case complex128:
= anyFieldC[complex128](Complex128)
case *complex128:
= anyFieldC[*complex128](Complex128p)
case []complex128:
= anyFieldC[[]complex128](Complex128s)
case complex64:
= anyFieldC[complex64](Complex64)
case *complex64:
= anyFieldC[*complex64](Complex64p)
case []complex64:
= anyFieldC[[]complex64](Complex64s)
case float64:
= anyFieldC[float64](Float64)
case *float64:
= anyFieldC[*float64](Float64p)
case []float64:
= anyFieldC[[]float64](Float64s)
case float32:
= anyFieldC[float32](Float32)
case *float32:
= anyFieldC[*float32](Float32p)
case []float32:
= anyFieldC[[]float32](Float32s)
case int:
= anyFieldC[int](Int)
case *int:
= anyFieldC[*int](Intp)
case []int:
= anyFieldC[[]int](Ints)
case int64:
= anyFieldC[int64](Int64)
case *int64:
= anyFieldC[*int64](Int64p)
case []int64:
= anyFieldC[[]int64](Int64s)
case int32:
= anyFieldC[int32](Int32)
case *int32:
= anyFieldC[*int32](Int32p)
case []int32:
= anyFieldC[[]int32](Int32s)
case int16:
= anyFieldC[int16](Int16)
case *int16:
= anyFieldC[*int16](Int16p)
case []int16:
= anyFieldC[[]int16](Int16s)
case int8:
= anyFieldC[int8](Int8)
case *int8:
= anyFieldC[*int8](Int8p)
case []int8:
= anyFieldC[[]int8](Int8s)
case string:
= anyFieldC[string](String)
case *string:
= anyFieldC[*string](Stringp)
case []string:
= anyFieldC[[]string](Strings)
case uint:
= anyFieldC[uint](Uint)
case *uint:
= anyFieldC[*uint](Uintp)
case []uint:
= anyFieldC[[]uint](Uints)
case uint64:
= anyFieldC[uint64](Uint64)
case *uint64:
= anyFieldC[*uint64](Uint64p)
case []uint64:
= anyFieldC[[]uint64](Uint64s)
case uint32:
= anyFieldC[uint32](Uint32)
case *uint32:
= anyFieldC[*uint32](Uint32p)
case []uint32:
= anyFieldC[[]uint32](Uint32s)
case uint16:
= anyFieldC[uint16](Uint16)
case *uint16:
= anyFieldC[*uint16](Uint16p)
case []uint16:
= anyFieldC[[]uint16](Uint16s)
case uint8:
= anyFieldC[uint8](Uint8)
case *uint8:
= anyFieldC[*uint8](Uint8p)
case []byte:
= anyFieldC[[]byte](Binary)
case uintptr:
= anyFieldC[uintptr](Uintptr)
case *uintptr:
= anyFieldC[*uintptr](Uintptrp)
case []uintptr:
= anyFieldC[[]uintptr](Uintptrs)
case time.Time:
= anyFieldC[time.Time](Time)
case *time.Time:
= anyFieldC[*time.Time](Timep)
case []time.Time:
= anyFieldC[[]time.Time](Times)
case time.Duration:
= anyFieldC[time.Duration](Duration)
case *time.Duration:
= anyFieldC[*time.Duration](Durationp)
case []time.Duration:
= anyFieldC[[]time.Duration](Durations)
case error:
= anyFieldC[error](NamedError)
case []error:
= anyFieldC[[]error](Errors)
case fmt.Stringer:
= anyFieldC[fmt.Stringer](Stringer)
default:
= anyFieldC[any](Reflect)
}
return .(, )
}