Versions in this module Expand all Collapse all v0 v0.1.1 Aug 28, 2026 v0.1.0 Jun 29, 2026 Changes in this version + const DurationFormatFloat + const DurationFormatInt + const DurationFormatString + const SlogLevelCrit + const SlogLevelDebug + const SlogLevelError + const SlogLevelInfo + const SlogLevelTrace + const SlogLevelWarn + const TimeFormatUnix + const TimeFormatUnixMicro + const TimeFormatUnixMs + const TimeFormatUnixNano + var CallerFieldName = "caller" + var CallerMarshalFunc = func(pc uintptr, file string, line int) string + var CallerSkipFrameCount = 2 + var DefaultContextLogger Logger + var DurationFieldFormat = DurationFormatFloat + var DurationFieldInteger = false + var DurationFieldUnit = time.Millisecond + var ErrUnknownLevel = errors.New("unknown log level") + var ErrorFieldName = "error" + var ErrorHandler func(err error) + var ErrorMarshalFunc = func(err error) interface{} + var ErrorStackFieldName = "stack" + var ErrorStackMarshaler func(err error) interface + var FloatingPointPrecision = -1 + var FormattedLevels = map[Level]string + var InterfaceMarshalFunc = func(v interface{}) ([]byte, error) + var LevelColors = map[Level]int + var LevelDebugValue = "debug" + var LevelErrorValue = "error" + var LevelFatalValue = "fatal" + var LevelFieldMarshalFunc = func(l Level) string + var LevelFieldName = "level" + var LevelInfoValue = "info" + var LevelPanicValue = "panic" + var LevelTraceValue = "trace" + var LevelWarnValue = "warn" + var MessageFieldName = "message" + var Often = RandomSampler(10) + var Rarely = RandomSampler(1000) + var Sometimes = RandomSampler(100) + var TimeFieldFormat = time.RFC3339 + var TimestampFieldName = "time" + var TimestampFunc = time.Now + var TriggerLevelWriterBufferReuseLimit = 64 * 1024 + func ConsoleTestWriter(t TestingLog) func(w *ConsoleWriter) + func Crit(msg string, ctx ...interface{}) + func Debug(msg string, ctx ...interface{}) + func DisableSampling(v bool) + func DiscardHandler() slog.Handler + func Error(msg string, ctx ...interface{}) + func Fatal(msg string, ctx ...interface{}) + func FormatLogfmtUint64(n uint64) string + func FormatSlogValue(v slog.Value, tmp []byte) (result []byte) + func FromLegacyLevel(lvl int) slog.Level + func Info(msg string, ctx ...interface{}) + func IsInternalPackage(pkg string) bool + func JSONHandler(wr io.Writer) slog.Handler + func JSONHandlerWithLevel(wr io.Writer, level slog.Leveler) slog.Handler + func LevelAlignedString(l slog.Level) string + func LevelString(l slog.Level) string + func Log(level Level, msg string, ctx ...interface{}) + func LogfmtHandler(wr io.Writer) slog.Handler + func LogfmtHandlerWithLevel(wr io.Writer, level slog.Leveler) slog.Handler + func LvlFromString(lvlString string) (slog.Level, error) + func RegisterInternalPackages(packages ...string) + func SetDefault(l Logger) + func SetGlobalLevel(l Level) + func SetSlogDefault(l SlogLogger) + func SyncWriter(w io.Writer) io.Writer + func Trace(msg string, ctx ...interface{}) + func Warn(msg string, ctx ...interface{}) + func WithContext(ctx context.Context, l Logger) context.Context + type Array struct + func Arr() *Array + func (*Array) MarshalLogArray(*Array) + func (a *Array) Bool(b bool) *Array + func (a *Array) Bytes(val []byte) *Array + func (a *Array) Dict(dict *Event) *Array + func (a *Array) Dur(d time.Duration) *Array + func (a *Array) Err(err error) *Array + func (a *Array) Errs(errs []error) *Array + func (a *Array) Float32(f float32) *Array + func (a *Array) Float64(f float64) *Array + func (a *Array) Hex(val []byte) *Array + func (a *Array) IPAddr(ip net.IP) *Array + func (a *Array) IPPrefix(pfx net.IPNet) *Array + func (a *Array) Int(i int) *Array + func (a *Array) Int16(i int16) *Array + func (a *Array) Int32(i int32) *Array + func (a *Array) Int64(i int64) *Array + func (a *Array) Int8(i int8) *Array + func (a *Array) Interface(i interface{}) *Array + func (a *Array) MACAddr(ha net.HardwareAddr) *Array + func (a *Array) Object(obj LogObjectMarshaler) *Array + func (a *Array) RawJSON(val []byte) *Array + func (a *Array) Str(val string) *Array + func (a *Array) Time(t time.Time) *Array + func (a *Array) Type(val interface{}) *Array + func (a *Array) Uint(i uint) *Array + func (a *Array) Uint16(i uint16) *Array + func (a *Array) Uint32(i uint32) *Array + func (a *Array) Uint64(i uint64) *Array + func (a *Array) Uint8(i uint8) *Array + type BasicSampler struct + N uint32 + func (s *BasicSampler) Sample(lvl Level) bool + type BurstSampler struct + Burst uint32 + NextSampler Sampler + Period time.Duration + func (s *BurstSampler) Sample(lvl Level) bool + type Color int + const Black + const Blue + const Bold + const Cyan + const DarkGray + const Green + const LightBlue + const LightCyan + const LightGray + const LightGreen + const LightPurple + const LightRed + const LightYellow + const Orange + const Purple + const Red + const Reset + const White + const Yellow + func (c Color) Wrap(s string) string + type Config struct + DisableWriterDisplaying bool + DisplayLevel Level + LogFormat LogFormat + LogLevel Level + type ConsoleWriter struct + FieldsExclude []string + FieldsOrder []string + FormatCaller Formatter + FormatErrFieldName Formatter + FormatErrFieldValue Formatter + FormatExtra func(map[string]interface{}, *bytes.Buffer) error + FormatFieldName Formatter + FormatFieldValue Formatter + FormatLevel Formatter + FormatMessage Formatter + FormatPartValueByName FormatterByFieldName + FormatPrepare func(map[string]interface{}) error + FormatTimestamp Formatter + NoColor bool + Out io.Writer + PartsExclude []string + PartsOrder []string + TimeFormat string + TimeLocation *time.Location + func NewConsoleWriter(options ...func(w *ConsoleWriter)) ConsoleWriter + func (w ConsoleWriter) Close() error + func (w ConsoleWriter) Write(p []byte) (n int, err error) + type Context struct + func (c Context) AnErr(key string, err error) Context + func (c Context) Any(key string, i interface{}) Context + func (c Context) Array(key string, arr LogArrayMarshaler) Context + func (c Context) Bool(key string, b bool) Context + func (c Context) Bools(key string, b []bool) Context + func (c Context) Bytes(key string, val []byte) Context + func (c Context) Caller() Context + func (c Context) CallerWithSkipFrameCount(skipFrameCount int) Context + func (c Context) CreateArray() *Array + func (c Context) CreateDict() *Event + func (c Context) Ctx(ctx context.Context) Context + func (c Context) Dict(key string, dict *Event) Context + func (c Context) Dur(key string, d time.Duration) Context + func (c Context) Durs(key string, d []time.Duration) Context + func (c Context) EmbedObject(obj LogObjectMarshaler) Context + func (c Context) Err(err error) Context + func (c Context) Errs(key string, errs []error) Context + func (c Context) Fields(fields interface{}) Context + func (c Context) Float32(key string, f float32) Context + func (c Context) Float64(key string, f float64) Context + func (c Context) Floats32(key string, f []float32) Context + func (c Context) Floats64(key string, f []float64) Context + func (c Context) Hex(key string, val []byte) Context + func (c Context) IPAddr(key string, ip net.IP) Context + func (c Context) IPAddrs(key string, ip []net.IP) Context + func (c Context) IPPrefix(key string, pfx net.IPNet) Context + func (c Context) IPPrefixes(key string, pfx []net.IPNet) Context + func (c Context) Int(key string, i int) Context + func (c Context) Int16(key string, i int16) Context + func (c Context) Int32(key string, i int32) Context + func (c Context) Int64(key string, i int64) Context + func (c Context) Int8(key string, i int8) Context + func (c Context) Interface(key string, i interface{}) Context + func (c Context) Ints(key string, i []int) Context + func (c Context) Ints16(key string, i []int16) Context + func (c Context) Ints32(key string, i []int32) Context + func (c Context) Ints64(key string, i []int64) Context + func (c Context) Ints8(key string, i []int8) Context + func (c Context) Logger() Logger + func (c Context) MACAddr(key string, ha net.HardwareAddr) Context + func (c Context) Object(key string, obj LogObjectMarshaler) Context + func (c Context) Objects(key string, objs []LogObjectMarshaler) Context + func (c Context) RawJSON(key string, b []byte) Context + func (c Context) Reset() Context + func (c Context) Stack() Context + func (c Context) Str(key, val string) Context + func (c Context) Stringer(key string, val fmt.Stringer) Context + func (c Context) Stringers(key string, vals []fmt.Stringer) Context + func (c Context) Strs(key string, vals []string) Context + func (c Context) Time(key string, t time.Time) Context + func (c Context) Times(key string, t []time.Time) Context + func (c Context) Timestamp() Context + func (c Context) Type(key string, val interface{}) Context + func (c Context) Uint(key string, i uint) Context + func (c Context) Uint16(key string, i uint16) Context + func (c Context) Uint32(key string, i uint32) Context + func (c Context) Uint64(key string, i uint64) Context + func (c Context) Uint8(key string, i uint8) Context + func (c Context) Uints(key string, i []uint) Context + func (c Context) Uints16(key string, i []uint16) Context + func (c Context) Uints32(key string, i []uint32) Context + func (c Context) Uints64(key string, i []uint64) Context + func (c Context) Uints8(key string, i []uint8) Context + type DedupSampler struct + MaxKeys int + Window time.Duration + func NewDedupSampler(window time.Duration) *DedupSampler + func (s *DedupSampler) GetSuppressedCount(lvl Level, msg string) int64 + func (s *DedupSampler) Sample(lvl Level) bool + func (s *DedupSampler) SampleMsg(lvl Level, msg string) bool + func (s *DedupSampler) SampleMsgWithKey(lvl Level, msg, key string) bool + type Event struct + func Dict() *Event + func (e *Event) AnErr(key string, err error) *Event + func (e *Event) Any(key string, i interface{}) *Event + func (e *Event) Array(key string, arr LogArrayMarshaler) *Event + func (e *Event) Bool(key string, b bool) *Event + func (e *Event) Bools(key string, b []bool) *Event + func (e *Event) Bytes(key string, val []byte) *Event + func (e *Event) Caller(skip ...int) *Event + func (e *Event) CallerSkipFrame(skip int) *Event + func (e *Event) CreateArray() *Array + func (e *Event) CreateDict() *Event + func (e *Event) Ctx(ctx context.Context) *Event + func (e *Event) Dict(key string, dict *Event) *Event + func (e *Event) Discard() *Event + func (e *Event) Dur(key string, d time.Duration) *Event + func (e *Event) Durs(key string, d []time.Duration) *Event + func (e *Event) EmbedObject(obj LogObjectMarshaler) *Event + func (e *Event) Enabled() bool + func (e *Event) Err(err error) *Event + func (e *Event) Errs(key string, errs []error) *Event + func (e *Event) Fields(fields interface{}) *Event + func (e *Event) Float32(key string, f float32) *Event + func (e *Event) Float64(key string, f float64) *Event + func (e *Event) Floats32(key string, f []float32) *Event + func (e *Event) Floats64(key string, f []float64) *Event + func (e *Event) Func(f func(e *Event)) *Event + func (e *Event) GetCtx() context.Context + func (e *Event) Hex(key string, val []byte) *Event + func (e *Event) IPAddr(key string, ip net.IP) *Event + func (e *Event) IPAddrs(key string, ip []net.IP) *Event + func (e *Event) IPPrefix(key string, pfx net.IPNet) *Event + func (e *Event) IPPrefixes(key string, pfx []net.IPNet) *Event + func (e *Event) Int(key string, i int) *Event + func (e *Event) Int16(key string, i int16) *Event + func (e *Event) Int32(key string, i int32) *Event + func (e *Event) Int64(key string, i int64) *Event + func (e *Event) Int8(key string, i int8) *Event + func (e *Event) Interface(key string, i interface{}) *Event + func (e *Event) Ints(key string, i []int) *Event + func (e *Event) Ints16(key string, i []int16) *Event + func (e *Event) Ints32(key string, i []int32) *Event + func (e *Event) Ints64(key string, i []int64) *Event + func (e *Event) Ints8(key string, i []int8) *Event + func (e *Event) MACAddr(key string, ha net.HardwareAddr) *Event + func (e *Event) Msg(msg string) + func (e *Event) MsgFunc(createMsg func() string) + func (e *Event) Msgf(format string, v ...interface{}) + func (e *Event) Object(key string, obj LogObjectMarshaler) *Event + func (e *Event) Objects(key string, objs []LogObjectMarshaler) *Event + func (e *Event) RawCBOR(key string, b []byte) *Event + func (e *Event) RawJSON(key string, b []byte) *Event + func (e *Event) Send() + func (e *Event) Stack() *Event + func (e *Event) Str(key, val string) *Event + func (e *Event) Stringer(key string, val fmt.Stringer) *Event + func (e *Event) Stringers(key string, vals []fmt.Stringer) *Event + func (e *Event) Strs(key string, vals []string) *Event + func (e *Event) Time(key string, t time.Time) *Event + func (e *Event) TimeDiff(key string, t time.Time, start time.Time) *Event + func (e *Event) Times(key string, t []time.Time) *Event + func (e *Event) Timestamp() *Event + func (e *Event) Type(key string, val interface{}) *Event + func (e *Event) Uint(key string, i uint) *Event + func (e *Event) Uint16(key string, i uint16) *Event + func (e *Event) Uint32(key string, i uint32) *Event + func (e *Event) Uint64(key string, i uint64) *Event + func (e *Event) Uint8(key string, i uint8) *Event + func (e *Event) Uints(key string, i []uint) *Event + func (e *Event) Uints16(key string, i []uint16) *Event + func (e *Event) Uints32(key string, i []uint32) *Event + func (e *Event) Uints64(key string, i []uint64) *Event + func (e *Event) Uints8(key string, i []uint8) *Event + type Factory interface + Close func() + GetDisplayLevel func(name string) (Level, error) + GetLogLevel func(name string) (Level, error) + Make func(name string) (Logger, error) + MakeChain func(alias string) (Logger, error) + MakeChainAndIndex func(alias string, index string) (Logger, Logger, error) + SetDisplayLevel func(name string, level Level) + SetLogLevel func(name string, level Level) + func NewFactory() Factory + func NewFactoryWithConfig(config Config) Factory + type Field struct + Key string + Value interface{} + func AnErr(key string, err error) Field + func Any(key string, val interface{}) Field + func Binary(key string, val []byte) Field + func Bool(key string, val bool) Field + func Bools(key string, val []bool) Field + func ByteString(key string, val []byte) Field + func Dur(key string, val time.Duration) Field + func Duration(key string, val time.Duration) Field + func Durations(key string, val []time.Duration) Field + func Err(err error) Field + func Float32(key string, val float32) Field + func Float64(key string, val float64) Field + func Float64s(key string, val []float64) Field + func Int(key string, val int) Field + func Int16(key string, val int16) Field + func Int32(key string, val int32) Field + func Int64(key string, val int64) Field + func Int64s(key string, val []int64) Field + func Int8(key string, val int8) Field + func Ints(key string, val []int) Field + func NamedErr(key string, err error) Field + func Reflect(key string, val interface{}) Field + func Stack(key string) Field + func Str(key, val string) Field + func String(key, val string) Field + func Stringer(key string, val fmt.Stringer) Field + func Strings(key string, val []string) Field + func Time(key string, val time.Time) Field + func Times(key string, val []time.Time) Field + func Uint(key string, val uint) Field + func Uint16(key string, val uint16) Field + func Uint32(key string, val uint32) Field + func Uint64(key string, val uint64) Field + func Uint64s(key string, val []uint64) Field + func Uint8(key string, val uint8) Field + func UserString(key, val string) Field + type FilteredLevelWriter struct + Level Level + Writer LevelWriter + func (w *FilteredLevelWriter) Close() error + func (w *FilteredLevelWriter) Write(p []byte) (int, error) + func (w *FilteredLevelWriter) WriteLevel(level Level, p []byte) (int, error) + type Formatter func(interface{}) string + type FormatterByFieldName func(interface{}, string) string + type GlogHandler struct + func NewGlogHandler(h slog.Handler) *GlogHandler + func (h *GlogHandler) Enabled(ctx context.Context, level slog.Level) bool + func (h *GlogHandler) Handle(ctx context.Context, r slog.Record) error + func (h *GlogHandler) Verbosity(level slog.Level) + func (h *GlogHandler) Vmodule(pattern string) error + func (h *GlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler + func (h *GlogHandler) WithGroup(name string) slog.Handler + type Hook interface + Run func(e *Event, level Level, message string) + type HookFunc func(e *Event, level Level, message string) + func (h HookFunc) Run(e *Event, level Level, message string) + type Level int8 + const DebugLevel + const Disabled + const ErrorLevel + const FatalLevel + const InfoLevel + const LevelCrit + const LevelDebug + const LevelError + const LevelInfo + const LevelTrace + const LevelWarn + const LvlDebug + const LvlInfo + const LvlTrace + const NoLevel + const PanicLevel + const TraceLevel + const WarnLevel + func GlobalLevel() Level + func ParseLevel(levelStr string) (Level, error) + func ToLevel(s string) (Level, error) + func (l *Level) UnmarshalText(text []byte) error + func (l Level) MarshalText() ([]byte, error) + func (l Level) String() string + type LevelHook struct + DebugHook Hook + ErrorHook Hook + FatalHook Hook + InfoHook Hook + NoLevelHook Hook + PanicHook Hook + TraceHook Hook + WarnHook Hook + func NewLevelHook() LevelHook + func (h LevelHook) Run(e *Event, level Level, message string) + type LevelSampler struct + DebugSampler Sampler + ErrorSampler Sampler + InfoSampler Sampler + TraceSampler Sampler + WarnSampler Sampler + func (s LevelSampler) Sample(lvl Level) bool + type LevelWriter interface + WriteLevel func(level Level, p []byte) (n int, err error) + func MultiLevelWriter(writers ...io.Writer) LevelWriter + type LevelWriterAdapter struct + func (lw LevelWriterAdapter) Close() error + func (lw LevelWriterAdapter) WriteLevel(l Level, p []byte) (n int, err error) + type LogArrayMarshaler interface + MarshalLogArray func(a *Array) + type LogFormat int + const Auto + const Colors + const JSON + const Plain + func ToFormat(s string, fd uintptr) (LogFormat, error) + type LogObjectMarshaler interface + MarshalLogObject func(e *Event) + type Logger interface + Crit func(msg string, ctx ...interface{}) + Debug func(msg string, ctx ...interface{}) + DebugEvent func() *Event + Enabled func(ctx context.Context, level slog.Level) bool + Err func(err error) *Event + Error func(msg string, ctx ...interface{}) + ErrorEvent func() *Event + Fatal func(msg string, ctx ...interface{}) + FatalEvent func() *Event + GetLevel func() Level + Hook func(hooks ...Hook) Logger + Info func(msg string, ctx ...interface{}) + InfoEvent func() *Event + IsZero func() bool + Level func(lvl Level) Logger + Log func(level Level, msg string, ctx ...interface{}) + LogEvent func() *Event + New func(ctx ...interface{}) Logger + Output func(w io.Writer) Logger + Panic func(msg string, ctx ...interface{}) + PanicEvent func() *Event + Print func(v ...interface{}) + Printf func(format string, v ...interface{}) + RecoverAndPanic func(fn func()) + Sample func(s Sampler) Logger + SetLogLevel func(level string) error + Trace func(msg string, ctx ...interface{}) + TraceEvent func() *Event + Verbo func(msg string, ctx ...interface{}) + Warn func(msg string, ctx ...interface{}) + WarnEvent func() *Event + With func() Context + WithLevel func(level Level) *Event + Write func(p []byte) (n int, err error) + func Ctx(ctx context.Context) Logger + func Default() Logger + func InitLogger(chainAlias string, logLevel string, jsonFormat bool, writer io.Writer) (Logger, error) + func New(ctx ...interface{}) Logger + func NewNoOpLogger() Logger + func NewTestLogger(level ...Level) Logger + func NewWriter(w io.Writer) Logger + func Noop() Logger + func Root() Logger + type NoLog struct + func (NoLog) Crit(string, ...interface{}) + func (NoLog) Debug(string, ...interface{}) + func (NoLog) DebugEvent() *Event + func (NoLog) Enabled(context.Context, slog.Level) bool + func (NoLog) Err(error) *Event + func (NoLog) Error(string, ...interface{}) + func (NoLog) ErrorEvent() *Event + func (NoLog) Fatal(string, ...interface{}) + func (NoLog) FatalEvent() *Event + func (NoLog) GetLevel() Level + func (NoLog) Hook(...Hook) Logger + func (NoLog) Info(string, ...interface{}) + func (NoLog) InfoEvent() *Event + func (NoLog) IsZero() bool + func (NoLog) Level(Level) Logger + func (NoLog) Log(Level, string, ...interface{}) + func (NoLog) LogEvent() *Event + func (NoLog) New(...interface{}) Logger + func (NoLog) Output(io.Writer) Logger + func (NoLog) Panic(string, ...interface{}) + func (NoLog) PanicEvent() *Event + func (NoLog) Print(...interface{}) + func (NoLog) Printf(string, ...interface{}) + func (NoLog) RecoverAndPanic(fn func()) + func (NoLog) Sample(Sampler) Logger + func (NoLog) SetLogLevel(string) error + func (NoLog) Trace(string, ...interface{}) + func (NoLog) TraceEvent() *Event + func (NoLog) Verbo(string, ...interface{}) + func (NoLog) Warn(string, ...interface{}) + func (NoLog) WarnEvent() *Event + func (NoLog) With() Context + func (NoLog) WithLevel(Level) *Event + func (NoLog) Write(p []byte) (int, error) + type RandomSampler uint32 + func (s RandomSampler) Sample(lvl Level) bool + type RotatingWriterConfig struct + Compress bool + Directory string + MaxAge int + MaxFiles int + MaxSize int + type Sampler interface + Sample func(lvl Level) bool + type SlogLogger interface + Crit func(msg string, ctx ...interface{}) + Debug func(msg string, ctx ...interface{}) + Enabled func(ctx context.Context, level slog.Level) bool + Error func(msg string, ctx ...interface{}) + Handler func() slog.Handler + Info func(msg string, ctx ...interface{}) + Log func(level slog.Level, msg string, ctx ...interface{}) + New func(ctx ...interface{}) SlogLogger + Trace func(msg string, ctx ...interface{}) + Warn func(msg string, ctx ...interface{}) + With func(ctx ...interface{}) SlogLogger + Write func(level slog.Level, msg string, attrs ...interface{}) + func NewLogger(h slog.Handler) SlogLogger + func NewLoggerFromHandler(h slog.Handler) SlogLogger + func SetupTerminalLogger(level slog.Level) SlogLogger + func SlogRoot() SlogLogger + type TerminalHandler struct + Prefix func(r slog.Record) string + func NewTerminalHandler(wr io.Writer, useColor bool) *TerminalHandler + func NewTerminalHandlerWithLevel(wr io.Writer, lvl slog.Leveler, useColor bool) *TerminalHandler + func (h *TerminalHandler) Enabled(_ context.Context, level slog.Level) bool + func (h *TerminalHandler) Handle(_ context.Context, r slog.Record) error + func (h *TerminalHandler) ResetFieldPadding() + func (h *TerminalHandler) WithAttrs(attrs []slog.Attr) slog.Handler + func (h *TerminalHandler) WithGroup(name string) slog.Handler + type TerminalStringer interface + TerminalString func() string + type TestWriter struct + Frame int + T TestingLog + func NewTestWriter(t TestingLog) TestWriter + func (t TestWriter) Write(p []byte) (n int, err error) + type TestingLog interface + Helper func() + Log func(args ...interface{}) + Logf func(format string, args ...interface{}) + type TriggerLevelWriter struct + ConditionalLevel Level + TriggerLevel Level + func (w *TriggerLevelWriter) Close() error + func (w *TriggerLevelWriter) Trigger() error + func (w *TriggerLevelWriter) WriteLevel(l Level, p []byte) (n int, err error)