Documentation
¶
Overview ¶
Package slogext is a small wrapper around the log/slog package focused on providing consistency in logging across the stencil codebase.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Level ¶
Level is a logging level.
const ( // DebugLevel is for debug level logs. DebugLevel Level = charmlog.DebugLevel // InfoLevel is for info level logs. InfoLevel Level = charmlog.InfoLevel // WarnLevel is for warn level logs. WarnLevel Level = charmlog.WarnLevel // ErrorLevel is for error level logs ErrorLevel Level = charmlog.ErrorLevel // FatalLevel is for fatal level logs. FatalLevel Level = charmlog.FatalLevel )
Contains valid Level values.
type Logger ¶
type Logger interface {
Info(string, ...any)
Infof(string, ...any)
Debug(string, ...any)
Debugf(string, ...any)
Error(string, ...any)
Errorf(string, ...any)
Warn(string, ...any)
Warnf(string, ...any)
With(...any) Logger
WithError(error) Logger
SetLevel(charmlog.Level)
GetHandler() slog.Handler
}
Logger is a slog.Logger interface with extra functionality.
func NewCapturedLogger ¶
NewCapturedLogger returns a Logger who's output is captured for future usage.
func NewNullLogger ¶
func NewNullLogger() Logger
NewNullLogger returns a Logger that does not output anywhere.
func NewTestLogger ¶
NewTestLogger creates a new logger for testing purposes. The logging level is set to DebugLevel to ensure all logs are captured.
func NewWithHandler ¶
NewWithHandler creates a new Logger using the slog package. Levels do not work since it is not a slog native concept.