Documentation
¶
Overview ¶
Package logger defines a common logging interface and provides implementations for various logging libraries.
Index ¶
- func ToContext(ctx context.Context, l Logger) context.Context
- type Logger
- type Nop
- func (Nop) Debug(_ ...any)
- func (Nop) Debugf(_ string, _ ...any)
- func (Nop) Error(_ ...any)
- func (Nop) Errorf(_ string, _ ...any)
- func (Nop) Fatal(_ ...any)
- func (Nop) Fatalf(_ string, _ ...any)
- func (Nop) Info(_ ...any)
- func (Nop) Infof(_ string, _ ...any)
- func (Nop) Warn(_ ...any)
- func (Nop) Warnf(_ string, _ ...any)
- func (Nop) With(_ ...any) Logger
- type Slog
- func (s *Slog) Debug(args ...any)
- func (s *Slog) Debugf(format string, args ...any)
- func (s *Slog) Error(args ...any)
- func (s *Slog) Errorf(format string, args ...any)
- func (s *Slog) Fatal(args ...any)
- func (s *Slog) Fatalf(format string, args ...any)
- func (s *Slog) Info(args ...any)
- func (s *Slog) Infof(format string, args ...any)
- func (s *Slog) Warn(args ...any)
- func (s *Slog) Warnf(format string, args ...any)
- func (s *Slog) With(args ...any) Logger
- func (s *Slog) WithContext(_ context.Context) *Slog
- type Zerolog
- func (z *Zerolog) Debug(args ...any)
- func (z *Zerolog) Debugf(format string, args ...any)
- func (z *Zerolog) Error(args ...any)
- func (z *Zerolog) Errorf(format string, args ...any)
- func (z *Zerolog) Fatal(args ...any)
- func (z *Zerolog) Fatalf(format string, args ...any)
- func (z *Zerolog) Info(args ...any)
- func (z *Zerolog) Infof(format string, args ...any)
- func (z *Zerolog) Warn(args ...any)
- func (z *Zerolog) Warnf(format string, args ...any)
- func (z *Zerolog) With(args ...any) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger interface {
// With returns a new logger with the given fields.
With(args ...any) Logger
// Error logs a message at the error level.
Error(args ...any)
// Errorf logs a message at the error level.
Errorf(format string, args ...any)
// Fatalf logs a message at the fatal level and calls os.Exit(1).
Fatalf(format string, args ...any)
// Fatal logs a message at the fatal level and calls os.Exit(1).
Fatal(args ...any)
// Info logs a message at the info level.
Info(args ...any)
// Infof logs a message at the info level.
Infof(format string, args ...any)
// Warn logs a message at the warn level.
Warn(args ...any)
// Warnf logs a message at the warn level.
Warnf(format string, args ...any)
// Debug logs a message at the debug level.
Debug(args ...any)
// Debugf logs a message at the debug level.
Debugf(format string, args ...any)
}
Logger is an interface for logging.
func FromContext ¶
FromContext returns the Logger associated with the context. If no Logger is found, it returns a Nop logger.
type Nop ¶
type Nop struct{}
Nop is a logger that does nothing.
type Slog ¶
type Slog struct {
// contains filtered or unexported fields
}
Slog is a logger that uses the standard library's log/slog package.
type Zerolog ¶
type Zerolog struct {
// contains filtered or unexported fields
}
Zerolog is a logger that uses the zerolog package.
Click to show internal directories.
Click to hide internal directories.