Documentation ¶
Overview ¶
Package zap provides a slog.Logger adaptor using a go.uber.org/zap Logger as backend
Index ¶
- func New(cfg *zap.Config) slog.Logger
- func NewDefaultConfig() *zap.Config
- type Logger
- func (zpl *Logger) Debug() slog.Logger
- func (zpl *Logger) Enabled() bool
- func (zpl *Logger) Error() slog.Logger
- func (zpl *Logger) Fatal() slog.Logger
- func (zpl *Logger) Info() slog.Logger
- func (zpl *Logger) NewWithCallback(fn func(lv zapcore.Entry) error) *Logger
- func (zpl *Logger) Panic() slog.Logger
- func (zpl *Logger) Print(args ...any)
- func (zpl *Logger) Printf(format string, args ...any)
- func (zpl *Logger) Println(args ...any)
- func (zpl *Logger) Unwrap() (*zap.Logger, *zap.Config)
- func (zpl *Logger) Warn() slog.Logger
- func (zpl *Logger) WithEnabled() (slog.Logger, bool)
- func (zpl *Logger) WithField(label string, value any) slog.Logger
- func (zpl *Logger) WithFields(fields map[string]any) slog.Logger
- func (zpl *Logger) WithLevel(level slog.LogLevel) slog.Logger
- func (zpl *Logger) WithStack(skip int) slog.Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates a slog.Logger adaptor using a zap as backend. If none was passed it will create an opiniated new one.
func NewDefaultConfig ¶ added in v0.3.7
NewDefaultConfig creates a new zap.Config logging to the console.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is an adaptor using go.uber.org/zap as slog.Logger
func NewNoop ¶
func NewNoop() *Logger
NewNoop returns a no-op Logger. It never writes out logs or internal errors
func (*Logger) NewWithCallback ¶
NewWithCallback creates a new zap logger using a callback to modify it.
func (*Logger) Println ¶
Println adds a log entry with arguments handled in the manner of fmt.Println
func (*Logger) WithEnabled ¶
WithEnabled passes the logger and if it's enabled
func (*Logger) WithFields ¶
WithFields returns a new logger with a set of fields attached