Documentation
¶
Index ¶
- Variables
- func Debug(msg string, args ...any)
- func Error(msg string, args ...any)
- func Fatal(msg string, args ...any)
- func Get() *slog.Logger
- func Info(msg string, args ...any)
- func Init(cfg *config.LoggerConfig) error
- func Named(name string) *slog.Logger
- func NewConditionalSourceHandler(handler slog.Handler, showSourceForLevels ...slog.Level) slog.Handler
- func SetLevel(level slog.Level)
- func Sync() error
- func Warn(msg string, args ...any)
- func WithComponent(component string) *slog.Logger
- func WithFields(args ...any) *slog.Logger
- type Interface
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Logger *slog.Logger
)
Functions ¶
func Init ¶
func Init(cfg *config.LoggerConfig) error
func NewConditionalSourceHandler ¶
func NewConditionalSourceHandler(handler slog.Handler, showSourceForLevels ...slog.Level) slog.Handler
NewConditionalSourceHandler wraps a handler to conditionally show source location based on log level. Source location is only shown for the specified levels. This is useful for reducing log volume in production while maintaining debuggability for important log levels.
The wrapped handler should have AddSource: false in its options. This wrapper will conditionally add source attributes for specified levels.
Example:
handler := NewConditionalSourceHandler(
tint.NewHandler(os.Stdout, opts),
slog.LevelWarn,
slog.LevelError,
)
func WithComponent ¶
func WithFields ¶
Types ¶
type Interface ¶
type Interface interface {
Debug(msg string, args ...any)
Info(msg string, args ...any)
Warn(msg string, args ...any)
Error(msg string, args ...any)
Fatal(msg string, args ...any)
With(args ...any) Interface
Named(name string) Interface
Debugw(msg string, keysAndValues ...interface{})
Infow(msg string, keysAndValues ...interface{})
Warnw(msg string, keysAndValues ...interface{})
Errorw(msg string, keysAndValues ...interface{})
Fatalw(msg string, keysAndValues ...interface{})
}
func NewLoggerWithSlog ¶
Click to show internal directories.
Click to hide internal directories.