Documentation
¶
Index ¶
- Constants
- func Span(ctx context.Context, attrs ...attribute.KeyValue) trace.Span
- type CallerEncoder
- type CheckedEntry
- type Core
- type DurationEncoder
- type Encoder
- type EncoderBuilder
- func (eb *EncoderBuilder) ConsoleEncoder() Encoder
- func (eb *EncoderBuilder) JsonEncoder() Encoder
- func (eb *EncoderBuilder) SensitiveEncoder() Encoder
- func (eb *EncoderBuilder) WithCallerKey(key string) *EncoderBuilder
- func (eb *EncoderBuilder) WithLevelKey(key string) *EncoderBuilder
- func (eb *EncoderBuilder) WithMessageKey(key string) *EncoderBuilder
- func (eb *EncoderBuilder) WithNameKey(key string) *EncoderBuilder
- func (eb *EncoderBuilder) WithTimeKey(key string) *EncoderBuilder
- type Entry
- type Field
- func Binary(key string, val []byte) Field
- func Bool(key string, val bool) Field
- func BoolPtr(key string, val *bool) Field
- func ByteString(key string, val []byte) Field
- func Complex64(key string, val complex64) Field
- func Complex64Ptr(key string, val *complex64) Field
- func Complex128(key string, val complex128) Field
- func Complex128Ptr(key string, val *complex128) Field
- func Duration(key string, val time.Duration) Field
- func DurationPtr(key string, val *time.Duration) Field
- func Error(err error) Field
- func Float32(key string, val float32) Field
- func Float32Ptr(key string, val *float32) Field
- func Float64(key string, val float64) Field
- func Float64Ptr(key string, val *float64) Field
- func Inline(val zapcore.ObjectMarshaler) Field
- func Int(key string, val int) Field
- func Int8(key string, val int8) Field
- func Int8Ptr(key string, val *int8) Field
- func Int16(key string, val int16) Field
- func Int16Ptr(key string, val *int16) Field
- func Int32(key string, val int32) Field
- func Int32Ptr(key string, val *int32) Field
- func Int64(key string, val int64) Field
- func Int64Ptr(key string, val *int64) Field
- func IntPtr(key string, val *int) Field
- func NamedError(key string, err error) Field
- func Namespace(key string) Field
- func Object(key string, val zapcore.ObjectMarshaler) Field
- func Reflect(key string, val interface{}) Field
- func Skip() Field
- func String(key string, val string) Field
- func StringPtr(key string, val *string) Field
- func Stringer(key string, val fmt.Stringer) Field
- func Strings(key string, ss []string) Field
- func Time(key string, val time.Time) Field
- func TimePtr(key string, val *time.Time) Field
- func Uint(key string, val uint) Field
- func Uint8(key string, val uint8) Field
- func Uint8Ptr(key string, val *uint8) Field
- func Uint16(key string, val uint16) Field
- func Uint16Ptr(key string, val *uint16) Field
- func Uint32(key string, val uint32) Field
- func Uint32Ptr(key string, val *uint32) Field
- func Uint64(key string, val uint64) Field
- func Uint64Ptr(key string, val *uint64) Field
- func UintPtr(key string, val *uint) Field
- func Uintptr(key string, val uintptr) Field
- func UintptrPtr(key string, val *uintptr) Field
- type FieldType
- type Hook
- type Level
- type LevelEncoder
- type Logger
- func (l *Logger) Check(lvl Level, msg string) *CheckedEntry
- func (l *Logger) Debug(msg string, fields ...Field)
- func (l *Logger) DebugCtx(ctx context.Context, msg string, fields ...Field)
- func (l *Logger) Error(msg string, fields ...Field)
- func (l *Logger) ErrorCtx(ctx context.Context, msg string, fields ...Field)
- func (l *Logger) ErrorOnErr(guideTxt string, err error, fields ...Field)
- func (l *Logger) Fatal(msg string, fields ...Field)
- func (l *Logger) FatalCtx(ctx context.Context, msg string, fields ...Field)
- func (l *Logger) Info(msg string, fields ...Field)
- func (l *Logger) InfoCtx(ctx context.Context, msg string, fields ...Field)
- func (l *Logger) LogEvent(event fxevent.Event)
- func (l *Logger) RecoverPanic(funcName string, extraInfo interface{}, compensationFunc func())
- func (l *Logger) SetLevel(lvl Level)
- func (l *Logger) Sugared() *SugaredLogger
- func (l *Logger) Sync() error
- func (l *Logger) Warn(msg string, fields ...Field)
- func (l *Logger) WarnCtx(ctx context.Context, msg string, fields ...Field)
- func (l *Logger) WarnOnErr(guideTxt string, err error, fields ...Field)
- func (l *Logger) With(name string) *Logger
- func (l *Logger) WithCore(core Core) *Logger
- func (l *Logger) WithSkip(name string, skipCaller int) *Logger
- type Option
- type Sensitive
- type SugaredLogger
- func (l SugaredLogger) Debug(template string, args ...any)
- func (l SugaredLogger) DebugCtx(ctx context.Context, template string, args ...any)
- func (l SugaredLogger) Error(template string, args ...any)
- func (l SugaredLogger) ErrorCtx(ctx context.Context, template string, args ...any)
- func (l SugaredLogger) Fatal(template string, args ...any)
- func (l SugaredLogger) Info(template string, args ...any)
- func (l SugaredLogger) InfoCtx(ctx context.Context, template string, args ...any)
- func (l SugaredLogger) Warn(template string, args ...any)
- func (l SugaredLogger) WarnCtx(ctx context.Context, template string, args ...any)
- type TimeEncoder
Constants ¶
const ( DebugLevel = zapcore.DebugLevel InfoLevel = zapcore.InfoLevel WarnLevel = zapcore.WarnLevel ErrorLevel = zapcore.ErrorLevel PanicLevel = zapcore.PanicLevel FatalLevel = zapcore.FatalLevel )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CallerEncoder ¶
type CallerEncoder = zapcore.CallerEncoder
type CheckedEntry ¶
type CheckedEntry = zapcore.CheckedEntry
type DurationEncoder ¶
type DurationEncoder = zapcore.DurationEncoder
type EncoderBuilder ¶
type EncoderBuilder struct {
// contains filtered or unexported fields
}
func NewEncoderBuilder ¶
func NewEncoderBuilder() *EncoderBuilder
func (*EncoderBuilder) ConsoleEncoder ¶
func (eb *EncoderBuilder) ConsoleEncoder() Encoder
func (*EncoderBuilder) JsonEncoder ¶
func (eb *EncoderBuilder) JsonEncoder() Encoder
func (*EncoderBuilder) SensitiveEncoder ¶
func (eb *EncoderBuilder) SensitiveEncoder() Encoder
func (*EncoderBuilder) WithCallerKey ¶
func (eb *EncoderBuilder) WithCallerKey(key string) *EncoderBuilder
func (*EncoderBuilder) WithLevelKey ¶
func (eb *EncoderBuilder) WithLevelKey(key string) *EncoderBuilder
func (*EncoderBuilder) WithMessageKey ¶
func (eb *EncoderBuilder) WithMessageKey(key string) *EncoderBuilder
func (*EncoderBuilder) WithNameKey ¶
func (eb *EncoderBuilder) WithNameKey(key string) *EncoderBuilder
func (*EncoderBuilder) WithTimeKey ¶
func (eb *EncoderBuilder) WithTimeKey(key string) *EncoderBuilder
type Field ¶
func Binary ¶
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 BoolPtr ¶
BoolPtr constructs a field that carries a *bool. The returned Field will safely and explicitly represent `nil` when appropriate.
func ByteString ¶
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 Complex64 ¶
Complex64 constructs a field that carries a complex number. Unlike most numeric fields, this costs an allocation (to convert the complex64 to interface{}).
func Complex64Ptr ¶
Complex64Ptr constructs a field that carries a *complex64. The returned Field will safely and explicitly represent `nil` when appropriate.
func Complex128 ¶
func Complex128(key string, val complex128) 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 Complex128Ptr ¶
func Complex128Ptr(key string, val *complex128) Field
Complex128Ptr constructs a field that carries a *complex128. The returned Field will safely and explicitly represent `nil` when appropriate.
func Duration ¶
Duration constructs a field with the given key and value. The encoder controls how the duration is serialized.
func DurationPtr ¶
DurationPtr constructs a field that carries a *time.Duration. The returned Field will safely and explicitly represent `nil` when appropriate.
func Float32 ¶
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 Float32Ptr ¶
Float32Ptr constructs a field that carries a *float32. The returned Field will safely and explicitly represent `nil` when appropriate.
func Float64 ¶
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 Float64Ptr ¶
Float64Ptr constructs a field that carries a *float64. The returned Field will safely and explicitly represent `nil` when appropriate.
func Inline ¶
func Inline(val zapcore.ObjectMarshaler) Field
Inline constructs a Field that is similar to Object, but it will add the elements of the provided ObjectMarshaller to the current namespace.
func Int8Ptr ¶
Int8Ptr constructs a field that carries a *int8. The returned Field will safely and explicitly represent `nil` when appropriate.
func Int16Ptr ¶
Int16Ptr constructs a field that carries a *int16. The returned Field will safely and explicitly represent `nil` when appropriate.
func Int32Ptr ¶
Int32Ptr constructs a field that carries a *int32. The returned Field will safely and explicitly represent `nil` when appropriate.
func Int64Ptr ¶
Int64Ptr constructs a field that carries a *int64. The returned Field will safely and explicitly represent `nil` when appropriate.
func IntPtr ¶
IntPtr constructs a field that carries a *int. The returned Field will safely and explicitly represent `nil` when appropriate.
func NamedError ¶
NamedError constructs a field that lazily stores err.Error() under the provided key. Errors which also implement fmt.Formatter (like those produced by github.com/pkg/errors) will also have their verbose representation stored under key+"Verbose". If passed a nil error, the field is a no-op.
For the common case in which the key is simply "error", the Error function is shorter and less repetitive.
func Namespace ¶
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 Object ¶
func Object(key string, val zapcore.ObjectMarshaler) 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 Reflect ¶
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 Skip ¶
func Skip() Field
Skip constructs a no-op field, which is often useful when handling invalid inputs in other Field constructors.
func StringPtr ¶
StringPtr constructs a field that carries a *string. The returned Field will safely and explicitly represent `nil` when appropriate.
func Stringer ¶
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 Time ¶
Time constructs a Field with the given key and value. The encoder controls how the time is serialized.
func TimePtr ¶
TimePtr constructs a field that carries a *time.Time. The returned Field will safely and explicitly represent `nil` when appropriate.
func Uint8Ptr ¶
Uint8Ptr constructs a field that carries a *uint8. The returned Field will safely and explicitly represent `nil` when appropriate.
func Uint16Ptr ¶
Uint16Ptr constructs a field that carries a *uint16. The returned Field will safely and explicitly represent `nil` when appropriate.
func Uint32Ptr ¶
Uint32Ptr constructs a field that carries a *uint32. The returned Field will safely and explicitly represent `nil` when appropriate.
func Uint64Ptr ¶
Uint64Ptr constructs a field that carries a *uint64. The returned Field will safely and explicitly represent `nil` when appropriate.
func UintPtr ¶
UintPtr constructs a field that carries a *uint. The returned Field will safely and explicitly represent `nil` when appropriate.
func UintptrPtr ¶
UintptrPtr constructs a field that carries a *uintptr. The returned Field will safely and explicitly represent `nil` when appropriate.
type LevelEncoder ¶
type LevelEncoder = zapcore.LevelEncoder
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a wrapper around zap.Logger and adds a good few features to it. It provides layered logs which could be used by separate packages, and could be turned off or on separately. Separate layers could also have independent log levels. Whenever you change log level it propagates through its children.
func (*Logger) ErrorOnErr ¶
func (*Logger) RecoverPanic ¶
func (*Logger) Sugared ¶
func (l *Logger) Sugared() *SugaredLogger
type Option ¶
type Option func(cfg *config)
func WithConsole ¶
func WithConsole() Option
func WithSkipCaller ¶
type SugaredLogger ¶
type SugaredLogger struct {
// contains filtered or unexported fields
}
func (SugaredLogger) Debug ¶
func (l SugaredLogger) Debug(template string, args ...any)
func (SugaredLogger) DebugCtx ¶
func (l SugaredLogger) DebugCtx(ctx context.Context, template string, args ...any)
func (SugaredLogger) Error ¶
func (l SugaredLogger) Error(template string, args ...any)
func (SugaredLogger) ErrorCtx ¶
func (l SugaredLogger) ErrorCtx(ctx context.Context, template string, args ...any)
func (SugaredLogger) Fatal ¶
func (l SugaredLogger) Fatal(template string, args ...any)
func (SugaredLogger) Info ¶
func (l SugaredLogger) Info(template string, args ...any)
func (SugaredLogger) InfoCtx ¶
func (l SugaredLogger) InfoCtx(ctx context.Context, template string, args ...any)
func (SugaredLogger) Warn ¶
func (l SugaredLogger) Warn(template string, args ...any)
type TimeEncoder ¶
type TimeEncoder = zapcore.TimeEncoder