Documentation ¶
Overview ¶
Package filter is a Logger that only allows entries of a given level
Index ¶
- func New(parent slog.Logger, threshold slog.LogLevel) slog.Logger
- func NewNoop() slog.Logger
- type LogEntry
- func (l *LogEntry) Debug() slog.Logger
- func (l *LogEntry) Enabled() bool
- func (l *LogEntry) Error() slog.Logger
- func (l *LogEntry) Fatal() slog.Logger
- func (l *LogEntry) Info() slog.Logger
- func (l *LogEntry) Panic() slog.Logger
- func (l *LogEntry) Print(args ...any)
- func (l *LogEntry) Printf(format string, args ...any)
- func (l *LogEntry) Println(args ...any)
- func (l *LogEntry) Warn() slog.Logger
- func (l *LogEntry) WithEnabled() (slog.Logger, bool)
- func (l *LogEntry) WithField(label string, value any) slog.Logger
- func (l *LogEntry) WithFields(fields map[string]any) slog.Logger
- func (l *LogEntry) WithLevel(level slog.LogLevel) slog.Logger
- func (l *LogEntry) WithStack(skip int) slog.Logger
- type Logger
- func (l *Logger) Debug() slog.Logger
- func (*Logger) Enabled() bool
- func (l *Logger) Error() slog.Logger
- func (l *Logger) Fatal() slog.Logger
- func (l *Logger) Info() slog.Logger
- func (l *Logger) Panic() slog.Logger
- func (*Logger) Print(...any)
- func (*Logger) Printf(string, ...any)
- func (*Logger) Println(...any)
- func (l *Logger) Warn() slog.Logger
- func (l *Logger) WithEnabled() (slog.Logger, bool)
- func (l *Logger) WithField(string, any) slog.Logger
- func (l *Logger) WithFields(map[string]any) slog.Logger
- func (l *Logger) WithLevel(level slog.LogLevel) slog.Logger
- func (l *Logger) WithStack(int) slog.Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LogEntry ¶
type LogEntry struct {
// contains filtered or unexported fields
}
LogEntry implements a level filtered logger
func (*LogEntry) Print ¶
Print would, if conditions are met, add a log entry with the arguments in the manner of fmt.Print
func (*LogEntry) Printf ¶
Printf would, if conditions are met, add a log entry with the arguments in the manner of fmt.Printf
func (*LogEntry) Println ¶
Println would, if conditions are met, add a log entry with the arguments in the manner of fmt.Println
func (*LogEntry) WithEnabled ¶
WithEnabled returns itself and if it's enabled
func (*LogEntry) WithField ¶
WithField would, if conditions are met, attach a field to the log entry. This field could be altered if a FieldFilter is used
func (*LogEntry) WithFields ¶
WithFields would, if conditions are met, attach fields to the log entry. These fields could be altered if a FieldFilter is used
type Logger ¶
type Logger struct { // Parent is the Logger to used as backend when conditions are met Parent slog.Logger // Threshold is the minimum level to be logged Threshold slog.LogLevel // FieldFilter allows us to modify filters before passing them // to the Parent logger FieldFilter func(key string, val any) (string, any, bool) // FieldOverride intercepts calls to WithField() on enabled loggers // to let you transform the field FieldOverride func(entry slog.Logger, key string, val any) // FieldsOverride intercepts calls to WithFields() on enabled loggers // to let you transform the fields FieldsOverride func(entry slog.Logger, fields map[string]any) // MessageFilter allows us to modify Print() messages before passing // them to the Parent logger, on completely discard the entry MessageFilter func(msg string) (string, bool) }
Logger implements a factory for level filtered loggers
func (*Logger) WithEnabled ¶
WithEnabled tells this logger doesn't log anything, but WithLevel() might
func (*Logger) WithFields ¶
WithFields does nothing