Documentation ¶
Overview ¶
Example ¶
log := New(DefaultConfig.Clone().SetWriter(os.Stdout)) log.Handler().(*SllmHandler).Clock = testClock log.Info("bad login `from` at `time`", `from`, "10.0.0.1") log.WithGroup("tests"). With("time", testClock()). Info("bad login `from` at `time`", `from`, "10.0.0.1")
Output: 06-01 Tu 12:13:14+01 INFO bad login `from:10.0.0.1` at `time:` 06-01 Tu 12:13:14+01 INFO [tests] bad login `from:10.0.0.1` at `time:1971-06-01 12:13:14.987654321 +0100 CET`
Index ¶
- Constants
- func Debug(msg string, args ...any)
- func DebugContext(ctx context.Context, msg string, args ...any)
- func Error(msg string, args ...any)
- func ErrorContext(ctx context.Context, msg string, args ...any)
- func Info(msg string, args ...any)
- func InfoContext(ctx context.Context, msg string, args ...any)
- func Log(ctx context.Context, level Level, msg string, args ...any)
- func LogAttrs(ctx context.Context, level Level, msg string, attrs ...slog.Attr)
- func Trace(msg string, args ...any)
- func TraceContext(ctx context.Context, msg string, args ...any)
- func Warn(msg string, args ...any)
- func WarnContext(ctx context.Context, msg string, args ...any)
- type AddSource
- type Config
- func (cfg *Config) AddSource() AddSource
- func (cfg *Config) Clone() *Config
- func (cfg *Config) Level() slog.Level
- func (cfg *Config) ParseFlag(f string) error
- func (cfg *Config) SetAddSource(s AddSource) *Config
- func (cfg *Config) SetLevel(l Level) *Config
- func (cfg *Config) SetTimeFmt(f sllm.TimeFormat) *Config
- func (cfg *Config) SetWriter(w io.Writer) *Config
- func (cfg *Config) TimeFmt() sllm.TimeFormat
- func (cfg *Config) Writer() (w io.Writer)
- type Level
- type Logger
- func (l *Logger) Enabled(ctx context.Context, level Level) bool
- func (l *Logger) Log(ctx context.Context, level Level, msg string, args ...any)
- func (l *Logger) LogAttrs(ctx context.Context, level Level, msg string, attrs ...slog.Attr)
- func (l *Logger) Trace(msg string, args ...any)
- func (l *Logger) TraceContext(ctx context.Context, msg string, args ...any)
- func (l *Logger) With(args ...any) *Logger
- func (l *Logger) WithGroup(name string) *Logger
- type SllmHandler
Examples ¶
Constants ¶
View Source
const ( LevelTrace = Level(2 * slog.LevelDebug) LevelDebug = Level(slog.LevelDebug) LevelInfo = Level(slog.LevelInfo) LevelWarn = Level(slog.LevelWarn) LevelError = Level(slog.LevelError) )
Variables ¶
This section is empty.
Functions ¶
func DebugContext ¶ added in v0.13.0
func ErrorContext ¶ added in v0.13.0
func TraceContext ¶ added in v0.13.0
Types ¶
type Config ¶ added in v0.13.0
type Config struct {
// contains filtered or unexported fields
}
var DefaultConfig Config
func (*Config) SetAddSource ¶ added in v0.13.0
func (*Config) SetTimeFmt ¶ added in v0.13.0
type Logger ¶
func (*Logger) TraceContext ¶ added in v0.13.0
type SllmHandler ¶ added in v0.13.0
func NewSllmHandler ¶ added in v0.13.0
func NewSllmHandler(cfg *Config) *SllmHandler
Click to show internal directories.
Click to hide internal directories.