Documentation
¶
Index ¶
- func CallerFrame() runtime.Frame
- func LevelFromString(s string) (slog.Level, error)
- func PrependSource(frame runtime.Frame, attrs []any) []any
- func SetLevelFromString(s string) error
- func Slog(module string) *slog.Logger
- func WriteRaw(msg string)
- type FanoutConfig
- type FanoutWriter
- type Logger
- func Debug(msg string, args ...any) *Logger
- func Debugf(format string, args ...any) *Logger
- func Error(msg string, args ...any) *Logger
- func Errorf(format string, args ...any) *Logger
- func For(module string) *Logger
- func Info(msg string, args ...any) *Logger
- func Infof(format string, args ...any) *Logger
- func Warn(msg string, args ...any) *Logger
- func Warnf(format string, args ...any) *Logger
- func With(args ...any) *Logger
- func (l *Logger) Debug(msg string, args ...any) *Logger
- func (l *Logger) Debugf(format string, args ...any) *Logger
- func (l *Logger) Error(msg string, args ...any) *Logger
- func (l *Logger) Errorf(format string, args ...any) *Logger
- func (l *Logger) Info(msg string, args ...any) *Logger
- func (l *Logger) Infof(format string, args ...any) *Logger
- func (l *Logger) Slog() *slog.Logger
- func (l *Logger) Warn(msg string, args ...any) *Logger
- func (l *Logger) Warnf(format string, args ...any) *Logger
- func (l *Logger) With(args ...any) *Logger
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallerFrame ¶ added in v1.22.6
CallerFrame returns the first stack frame outside log package wrappers (business log only).
func LevelFromString ¶
LevelFromString maps go-log style level names to slog.Level.
func PrependSource ¶ added in v1.22.6
PrependSource adds source=file:line when enabled (for slog integrations such as GORM).
func SetLevelFromString ¶
SetLevelFromString changes global log level at runtime.
Types ¶
type FanoutConfig ¶ added in v1.22.6
type FanoutConfig struct {
Buffer int // channel capacity; default 256
WriteTimeout time.Duration // per-backend write deadline; default 2s
Cooldown time.Duration // blacklist duration after timeout; default 30s
}
FanoutConfig controls async fan-out behavior.
func DefaultFanoutConfig ¶ added in v1.22.6
func DefaultFanoutConfig() FanoutConfig
type FanoutWriter ¶ added in v1.22.6
type FanoutWriter struct {
// contains filtered or unexported fields
}
FanoutWriter duplicates log lines to multiple io.Writer backends asynchronously.
func NewFanout ¶ added in v1.22.6
func NewFanout(ctx context.Context, writers ...io.Writer) *FanoutWriter
NewFanout returns a fan-out writer with DefaultFanoutConfig.
func NewFanoutBuffer ¶ added in v1.22.6
func NewFanoutBuffer(size int, writers ...io.Writer) *FanoutWriter
NewFanoutBuffer is deprecated naming; use NewFanoutConfig.
func NewFanoutConfig ¶ added in v1.22.6
func NewFanoutConfig(ctx context.Context, cfg FanoutConfig, writers ...io.Writer) *FanoutWriter
NewFanoutConfig builds a fan-out writer. ctx cancellation stops the worker.
func (*FanoutWriter) BackendTimeouts ¶ added in v1.22.6
func (f *FanoutWriter) BackendTimeouts() uint64
BackendTimeouts returns how many backend writes hit the timeout.
func (*FanoutWriter) Close ¶ added in v1.22.6
func (f *FanoutWriter) Close() error
Close drains pending lines and stops the worker.
func (*FanoutWriter) Dropped ¶ added in v1.22.6
func (f *FanoutWriter) Dropped() uint64
Dropped returns lines dropped (channel full or shed after backend timeout).
func (*FanoutWriter) TimeoutDrops ¶ added in v1.22.6
func (f *FanoutWriter) TimeoutDrops() uint64
TimeoutDrops returns lines not delivered due to backend write timeouts.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger wraps slog with optional fixed module and chainable With.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options builds slog handler settings (chainable).
func (*Options) Apply ¶
func (c *Options) Apply()
Apply installs handler as slog.Default and package default.
func (*Options) Caller ¶ added in v1.22.6
Caller enables source file:line on each record; entries attach source= via stack walk (default off).