Documentation
¶
Index ¶
- func Debug(ctx context.Context, msg string, tags ...slog.Attr)
- func Debugf(ctx context.Context, format string, v ...any)
- func Error(ctx context.Context, msg string, tags ...slog.Attr)
- func Errorf(ctx context.Context, format string, v ...any)
- func Fatal(ctx context.Context, msg string, tags ...slog.Attr)
- func Fatalf(ctx context.Context, format string, v ...any)
- func Info(ctx context.Context, msg string, tags ...slog.Attr)
- func Infof(ctx context.Context, format string, v ...any)
- func Warn(ctx context.Context, msg string, tags ...slog.Attr)
- func Warnf(ctx context.Context, format string, v ...any)
- func WithFixedLogger(ctx context.Context, logger Logger) context.Context
- func WithLogger(ctx context.Context, logger Logger) context.Context
- func WithValues(ctx context.Context, attrs ...slog.Attr) context.Context
- func Write(ctx context.Context, msg string)
- type Config
- type Logger
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithFixedLogger ¶
WithFixedLogger returns a new context with the given fixed logger. This is only used for testing.
func WithLogger ¶
WithLogger returns a new context with the given logger.
func WithValues ¶
WithValues adds attributes to the context for structured logging
Types ¶
type Logger ¶
type Logger interface {
Debug(msg string, tags ...slog.Attr)
Info(msg string, tags ...slog.Attr)
Warn(msg string, tags ...slog.Attr)
Error(msg string, tags ...slog.Attr)
Fatal(msg string, tags ...slog.Attr)
Debugf(format string, v ...any)
Infof(format string, v ...any)
Warnf(format string, v ...any)
Errorf(format string, v ...any)
Fatalf(format string, v ...any)
With(attrs ...slog.Attr) Logger
WithGroup(name string) Logger
// Write writes a message to the logger in free form.
Write(string)
}
func FromContext ¶
FromContext returns a logger from the given context.
type Option ¶
type Option func(*Config)
func WithFormat ¶
WithFormat sets the format of the logger (text or json).
Click to show internal directories.
Click to hide internal directories.