Documentation
¶
Index ¶
- Constants
- Variables
- type Configuration
- type Logger
- type SlogLogger
- func (log *SlogLogger) Close() error
- func (log *SlogLogger) Debug(msg string, fields ...slog.Attr)
- func (log *SlogLogger) DebugWithContext(ctx context.Context, msg string, fields ...slog.Attr)
- func (log *SlogLogger) Error(msg string, fields ...slog.Attr)
- func (log *SlogLogger) ErrorWithContext(ctx context.Context, msg string, fields ...slog.Attr)
- func (log *SlogLogger) Info(msg string, fields ...slog.Attr)
- func (log *SlogLogger) InfoWithContext(ctx context.Context, msg string, fields ...slog.Attr)
- func (log *SlogLogger) Warn(msg string, fields ...slog.Attr)
- func (log *SlogLogger) WarnWithContext(ctx context.Context, msg string, fields ...slog.Attr)
Constants ¶
View Source
const ( // ErrorLevel level. Logs. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. ERROR_LEVEL int = iota // WarnLevel level. Non-critical entries that deserve eyes. WARN_LEVEL // InfoLevel level. General operational entries about what's going on inside the // application. INFO_LEVEL // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DEBUG_LEVEL )
The severity levels. Higher values are more considered more important.
Variables ¶
View Source
var ErrInvalidLogLevel = errors.New("invalid log level")
ErrInvalidLogLevel is an error when log level is invalid.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
Configuration - options for logger.
func (*Configuration) Validate ¶
func (c *Configuration) Validate() error
type Logger ¶
type Logger interface {
Error(msg string, fields ...slog.Attr)
ErrorWithContext(ctx context.Context, msg string, fields ...slog.Attr)
Warn(msg string, fields ...slog.Attr)
WarnWithContext(ctx context.Context, msg string, fields ...slog.Attr)
Info(msg string, fields ...slog.Attr)
InfoWithContext(ctx context.Context, msg string, fields ...slog.Attr)
Debug(msg string, fields ...slog.Attr)
DebugWithContext(ctx context.Context, msg string, fields ...slog.Attr)
// Closer is the interface that wraps the basic Close method.
io.Closer
}
Logger is our contract for the logger.
type SlogLogger ¶
type SlogLogger struct {
// contains filtered or unexported fields
}
func New ¶
func New(cfg Configuration) (*SlogLogger, error)
func NewDefault ¶
New creates a new logger instance using the provided configuration.
func (*SlogLogger) Close ¶
func (log *SlogLogger) Close() error
func (*SlogLogger) DebugWithContext ¶
func (*SlogLogger) ErrorWithContext ¶
func (*SlogLogger) InfoWithContext ¶
func (*SlogLogger) WarnWithContext ¶
Click to show internal directories.
Click to hide internal directories.