Documentation
¶
Index ¶
- type EnabledContextLogger
- type EnabledLogger
- type LeveledContextLogger
- type LeveledFormatContextLogger
- type LeveledFormatLogger
- type LeveledLineContextLogger
- type LeveledLineLogger
- type LeveledLogger
- type PrintContextLogger
- type PrintFormatContextLogger
- type PrintFormatLogger
- type PrintLineContextLogger
- type PrintLineLogger
- type PrintLogger
- type SlogAdapter
- func New(logger *slog.Logger, level slog.Level) *SlogAdapter
- func NewDefault() *SlogAdapter
- func NewDiscard() *SlogAdapter
- func NewJSON(writer io.Writer, level slog.Level) *SlogAdapter
- func NewLevel(level slog.Level) *SlogAdapter
- func NewLogger(logger *slog.Logger) *SlogAdapter
- func NewText(writer io.Writer, level slog.Level) *SlogAdapter
- func (a *SlogAdapter) Debug(msg ...interface{})
- func (a *SlogAdapter) DebugContext(ctx context.Context, msg ...interface{})
- func (a *SlogAdapter) Debugf(format string, args ...interface{})
- func (a *SlogAdapter) DebugfContext(ctx context.Context, format string, args ...interface{})
- func (a *SlogAdapter) Debugln(msg ...interface{})
- func (a *SlogAdapter) DebuglnContext(ctx context.Context, msg ...interface{})
- func (a *SlogAdapter) Enabled() bool
- func (a *SlogAdapter) EnabledContext(ctx context.Context) bool
- func (a *SlogAdapter) Error(msg ...interface{})
- func (a *SlogAdapter) ErrorContext(ctx context.Context, msg ...interface{})
- func (a *SlogAdapter) Errorf(format string, args ...interface{})
- func (a *SlogAdapter) ErrorfContext(ctx context.Context, format string, args ...interface{})
- func (a *SlogAdapter) Errorln(msg ...interface{})
- func (a *SlogAdapter) ErrorlnContext(ctx context.Context, msg ...interface{})
- func (a *SlogAdapter) Info(msg ...interface{})
- func (a *SlogAdapter) InfoContext(ctx context.Context, msg ...interface{})
- func (a *SlogAdapter) Infof(format string, args ...interface{})
- func (a *SlogAdapter) InfofContext(ctx context.Context, format string, args ...interface{})
- func (a *SlogAdapter) Infoln(msg ...interface{})
- func (a *SlogAdapter) InfolnContext(ctx context.Context, msg ...interface{})
- func (a *SlogAdapter) Level() slog.Level
- func (a *SlogAdapter) Logger() *slog.Logger
- func (a *SlogAdapter) Print(msg ...interface{})
- func (a *SlogAdapter) PrintContext(ctx context.Context, msg ...interface{})
- func (a *SlogAdapter) Printf(format string, args ...interface{})
- func (a *SlogAdapter) PrintfContext(ctx context.Context, format string, args ...interface{})
- func (a *SlogAdapter) Println(msg ...interface{})
- func (a *SlogAdapter) PrintlnContext(ctx context.Context, msg ...interface{})
- func (a *SlogAdapter) Warn(msg ...interface{})
- func (a *SlogAdapter) WarnContext(ctx context.Context, msg ...interface{})
- func (a *SlogAdapter) Warnf(format string, args ...interface{})
- func (a *SlogAdapter) WarnfContext(ctx context.Context, format string, args ...interface{})
- func (a *SlogAdapter) Warnln(msg ...interface{})
- func (a *SlogAdapter) WarnlnContext(ctx context.Context, msg ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnabledContextLogger ¶
type EnabledContextLogger interface { // EnabledContext is the same implementation as [EnabledLogger.Enabled] // with the addition of a custom context EnabledContext(ctx context.Context) bool }
EnabledContextLogger is the same implementation as EnabledLogger with the addition of a custom context
type EnabledLogger ¶
type EnabledLogger interface {
Enabled() bool
}
Contract to provide reporting capabilities about an instance state
type LeveledContextLogger ¶
type LeveledContextLogger interface { // ErrorContext is the same implementation as [LeveledLogger.Error] // with the addition of a custom context ErrorContext(ctx context.Context, msg ...interface{}) // InfoContext is the same implementation as [LeveledLogger.Info] // with the addition of a custom context InfoContext(ctx context.Context, msg ...interface{}) // DebugContext is the same implementation as [LeveledLogger.Debug] // with the addition of a custom context DebugContext(ctx context.Context, msg ...interface{}) // WarnContext is the same implementation as [LeveledLogger.Warn] // with the addition of a custom context WarnContext(ctx context.Context, msg ...interface{}) }
LeveledContextLogger is the same implementation as LeveledLogger with the addition of a custom context
type LeveledFormatContextLogger ¶
type LeveledFormatContextLogger interface { // ErrorfContext is the same implementation as [LeveledFormatLogger.Errorf] // with the addition of a custom context ErrorfContext(ctx context.Context, format string, args ...interface{}) // InfofContext is the same implementation as [LeveledFormatLogger.Infof] // with the addition of a custom context InfofContext(ctx context.Context, format string, args ...interface{}) // DebugfContext is the same implementation as [LeveledFormatLogger.Debugf] // with the addition of a custom context DebugfContext(ctx context.Context, format string, args ...interface{}) // WarnfContext is the same implementation as [LeveledFormatLogger.Warnf] // with the addition of a custom context WarnfContext(ctx context.Context, format string, args ...interface{}) }
LeveledFormatContextLogger is the same implementation as LeveledFormatLogger with the addition of a custom context
type LeveledFormatLogger ¶
type LeveledFormatLogger interface { Errorf(format string, args ...interface{}) Infof(format string, args ...interface{}) Debugf(format string, args ...interface{}) Warnf(format string, args ...interface{}) }
Logger implementation using fmt.Printf as message renderer
type LeveledLineContextLogger ¶
type LeveledLineContextLogger interface { // ErrorlnContext is the same implementation as [LeveledLineLogger.Errorln] // with the addition of a custom context ErrorlnContext(ctx context.Context, msg ...interface{}) // InfolnContext is the same implementation as [LeveledLineLogger.Infoln] // with the addition of a custom context InfolnContext(ctx context.Context, msg ...interface{}) // DebuglnContext is the same implementation as [LeveledLineLogger.Debugln] // with the addition of a custom context DebuglnContext(ctx context.Context, msg ...interface{}) // WarnlnContext is the same implementation as [LeveledLineLogger.Warnln] // with the addition of a custom context WarnlnContext(ctx context.Context, msg ...interface{}) }
LeveledLineContextLogger is the same implementation as LeveledLineLogger with the addition of a custom context
type LeveledLineLogger ¶
type LeveledLineLogger interface { Errorln(msg ...interface{}) Infoln(msg ...interface{}) Debugln(msg ...interface{}) Warnln(msg ...interface{}) }
Logger implementation using fmt.Print as message renderer
type LeveledLogger ¶
type LeveledLogger interface { Error(msg ...interface{}) Info(msg ...interface{}) Debug(msg ...interface{}) Warn(msg ...interface{}) }
Logger implementation using fmt.Print as message renderer
type PrintContextLogger ¶
type PrintContextLogger interface { // PrintContext is the same implementation as [PrintLogger.Print] // with the addition of a custom context PrintContext(ctx context.Context, msg ...interface{}) }
PrintContextLogger is the same implementation as PrintLogger with the addition of a custom context
type PrintFormatContextLogger ¶
type PrintFormatContextLogger interface { // PrintfContext is the same implementation as [PrintFormatLogger.Printf] // with the addition of a custom context PrintfContext(ctx context.Context, format string, args ...interface{}) }
PrintFormatContextLogger is the same implementation as PrintFormatLogger with the addition of a custom context
type PrintFormatLogger ¶
type PrintFormatLogger interface {
Printf(format string, args ...interface{})
}
Logger implementation using fmt.Printf as message renderer
type PrintLineContextLogger ¶
type PrintLineContextLogger interface { // PrintlnContext is the same implementation as [PrintLineLogger.Println] // with the addition of a custom context PrintlnContext(ctx context.Context, msg ...interface{}) }
PrintLineContextLogger is the same implementation as PrintLineLogger with the addition of a custom context
type PrintLineLogger ¶
type PrintLineLogger interface {
Println(msg ...interface{})
}
Logger implementation using fmt.Print as message renderer
type PrintLogger ¶
type PrintLogger interface {
Print(msg ...interface{})
}
Logger implementation using fmt.Print as message renderer
type SlogAdapter ¶
type SlogAdapter struct {
// contains filtered or unexported fields
}
Logging adapter for structured logging. It implements a variety of log functions suitable for various custom logging contracts.
func New ¶
func New(logger *slog.Logger, level slog.Level) *SlogAdapter
New returns a SlogAdapter instance using the provided slog.Logger as data sink. The slog.Level is used as default value for logging functions without an explicit level semantic attached to it.
func NewDefault ¶
func NewDefault() *SlogAdapter
NewLevel returns a New instance using the slog.Default instance as data sink and slog.LevelInfo as default value for logging functions without an explicit level semantic attached to it.
func NewDiscard ¶ added in v0.3.0
func NewDiscard() *SlogAdapter
NewDiscard uses NewText with io.Discard as writer. The log level threshold is set high to cause the internal logic to bail early instead of spending CPU cycles on producing a log record that is never actually used.
func NewJSON ¶
func NewJSON(writer io.Writer, level slog.Level) *SlogAdapter
NewJSON creates a New instance using a slog.JSONHandler with the provided writer and level.
func NewLevel ¶
func NewLevel(level slog.Level) *SlogAdapter
NewLevel returns a New instance using the slog.Default instance as data sink. The slog.Level is used as default value for logging functions without an explicit level semantic attached to it.
func NewLogger ¶
func NewLogger(logger *slog.Logger) *SlogAdapter
NewLogger returns a New instance using the provided slog.Logger as data sink and slog.LevelInfo as default value for logging functions without an explicit level semantic attached to it.
func NewText ¶
func NewText(writer io.Writer, level slog.Level) *SlogAdapter
NewText creates a New instance using a slog.TextHandler with the provided writer and level.
func (*SlogAdapter) Debug ¶
func (a *SlogAdapter) Debug(msg ...interface{})
func (*SlogAdapter) DebugContext ¶
func (a *SlogAdapter) DebugContext(ctx context.Context, msg ...interface{})
func (*SlogAdapter) Debugf ¶
func (a *SlogAdapter) Debugf(format string, args ...interface{})
func (*SlogAdapter) DebugfContext ¶
func (a *SlogAdapter) DebugfContext(ctx context.Context, format string, args ...interface{})
func (*SlogAdapter) Debugln ¶
func (a *SlogAdapter) Debugln(msg ...interface{})
func (*SlogAdapter) DebuglnContext ¶
func (a *SlogAdapter) DebuglnContext(ctx context.Context, msg ...interface{})
func (*SlogAdapter) Enabled ¶
func (a *SlogAdapter) Enabled() bool
func (*SlogAdapter) EnabledContext ¶
func (a *SlogAdapter) EnabledContext(ctx context.Context) bool
func (*SlogAdapter) Error ¶
func (a *SlogAdapter) Error(msg ...interface{})
func (*SlogAdapter) ErrorContext ¶
func (a *SlogAdapter) ErrorContext(ctx context.Context, msg ...interface{})
func (*SlogAdapter) Errorf ¶
func (a *SlogAdapter) Errorf(format string, args ...interface{})
func (*SlogAdapter) ErrorfContext ¶
func (a *SlogAdapter) ErrorfContext(ctx context.Context, format string, args ...interface{})
func (*SlogAdapter) Errorln ¶
func (a *SlogAdapter) Errorln(msg ...interface{})
func (*SlogAdapter) ErrorlnContext ¶
func (a *SlogAdapter) ErrorlnContext(ctx context.Context, msg ...interface{})
func (*SlogAdapter) Info ¶
func (a *SlogAdapter) Info(msg ...interface{})
func (*SlogAdapter) InfoContext ¶
func (a *SlogAdapter) InfoContext(ctx context.Context, msg ...interface{})
func (*SlogAdapter) Infof ¶
func (a *SlogAdapter) Infof(format string, args ...interface{})
func (*SlogAdapter) InfofContext ¶
func (a *SlogAdapter) InfofContext(ctx context.Context, format string, args ...interface{})
func (*SlogAdapter) Infoln ¶
func (a *SlogAdapter) Infoln(msg ...interface{})
func (*SlogAdapter) InfolnContext ¶
func (a *SlogAdapter) InfolnContext(ctx context.Context, msg ...interface{})
func (*SlogAdapter) Level ¶
func (a *SlogAdapter) Level() slog.Level
Level returns the configured slog.Level
func (*SlogAdapter) Logger ¶
func (a *SlogAdapter) Logger() *slog.Logger
Logger returns the internal slog.Logger instance
func (*SlogAdapter) Print ¶
func (a *SlogAdapter) Print(msg ...interface{})
func (*SlogAdapter) PrintContext ¶
func (a *SlogAdapter) PrintContext(ctx context.Context, msg ...interface{})
func (*SlogAdapter) Printf ¶
func (a *SlogAdapter) Printf(format string, args ...interface{})
func (*SlogAdapter) PrintfContext ¶
func (a *SlogAdapter) PrintfContext(ctx context.Context, format string, args ...interface{})
func (*SlogAdapter) Println ¶
func (a *SlogAdapter) Println(msg ...interface{})
func (*SlogAdapter) PrintlnContext ¶
func (a *SlogAdapter) PrintlnContext(ctx context.Context, msg ...interface{})
func (*SlogAdapter) Warn ¶
func (a *SlogAdapter) Warn(msg ...interface{})
func (*SlogAdapter) WarnContext ¶
func (a *SlogAdapter) WarnContext(ctx context.Context, msg ...interface{})
func (*SlogAdapter) Warnf ¶
func (a *SlogAdapter) Warnf(format string, args ...interface{})
func (*SlogAdapter) WarnfContext ¶
func (a *SlogAdapter) WarnfContext(ctx context.Context, format string, args ...interface{})
func (*SlogAdapter) Warnln ¶
func (a *SlogAdapter) Warnln(msg ...interface{})
func (*SlogAdapter) WarnlnContext ¶
func (a *SlogAdapter) WarnlnContext(ctx context.Context, msg ...interface{})