chore: upgrade dependencies
This commit is contained in:
1 parent
fb20ef0d06
commit
f960fcc768
21 files changed
+650
-422
No files matched your search
+24
-1
@@ -25,6 +25,7 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap/internal/stacktrace"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
@@ -374,7 +375,7 @@ func StackSkip(key string, skip int) Field {
|
||||
// from expanding the zapcore.Field union struct to include a byte slice. Since
|
||||
// taking a stacktrace is already so expensive (~10us), the extra allocation
|
||||
// is okay.
|
||||
return String(key, takeStacktrace(skip+1)) // skip StackSkip
|
||||
return String(key, stacktrace.Take(skip+1)) // skip StackSkip
|
||||
}
|
||||
|
||||
// Duration constructs a field with the given key and value. The encoder
|
||||
@@ -410,6 +411,26 @@ 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 {
|
||||
return dictField(key, val)
|
||||
}
|
||||
|
||||
// We need a function with the signature (string, T) for zap.Any.
|
||||
func dictField(key string, val []Field) Field {
|
||||
return Object(key, dictObject(val))
|
||||
}
|
||||
|
||||
type dictObject []Field
|
||||
|
||||
func (d dictObject) MarshalLogObject(enc zapcore.ObjectEncoder) error {
|
||||
for _, f := range d {
|
||||
f.AddTo(enc)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// We discovered an issue where zap.Any can cause a performance degradation
|
||||
// when used in new goroutines.
|
||||
//
|
||||
@@ -462,6 +483,8 @@ func Any(key string, value interface{}) Field {
|
||||
c = anyFieldC[zapcore.ObjectMarshaler](Object)
|
||||
case zapcore.ArrayMarshaler:
|
||||
c = anyFieldC[zapcore.ArrayMarshaler](Array)
|
||||
case []Field:
|
||||
c = anyFieldC[[]Field](dictField)
|
||||
case bool:
|
||||
c = anyFieldC[bool](Bool)
|
||||
case *bool:
|
||||
|
||||
Reference in new issue
Block a user