logging

package
v2.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0, Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(debugEnabled DebugEnabledFunc) *slog.Logger

NewLogger creates a new logger with dynamic debug checking

Types

type DebugCheckHandler

type DebugCheckHandler struct {
	// contains filtered or unexported fields
}

DebugCheckHandler checks settings.Debug at log time

func (*DebugCheckHandler) Enabled

func (h *DebugCheckHandler) Enabled(_ context.Context, level slog.Level) bool

Enabled implements slog.Handler.Enabled

func (*DebugCheckHandler) Handle

func (h *DebugCheckHandler) Handle(ctx context.Context, r slog.Record) error

Handle implements slog.Handler.Handle

func (*DebugCheckHandler) WithAttrs

func (h *DebugCheckHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs implements slog.Handler.WithAttrs

func (*DebugCheckHandler) WithGroup

func (h *DebugCheckHandler) WithGroup(name string) slog.Handler

WithGroup implements slog.Handler.WithGroup

type DebugEnabledFunc

type DebugEnabledFunc func() bool

DebugEnabledFunc is a function type that determines if debug logging is enabled We use a function because we want to check the setting at log time, not when the logger is created

type LogHolder

type LogHolder struct {
	// contains filtered or unexported fields
}

func (*LogHolder) Logger

func (l *LogHolder) Logger() *slog.Logger

Logger returns the logger for the LogHolder. If nil, returns slog.Default().

func (*LogHolder) SetLogger

func (l *LogHolder) SetLogger(newHandler slog.Handler)

SetLogger sets the logger for the LogHolder. If nil, sets the default logger.

type LoggerSetterGetter

type LoggerSetterGetter interface {
	// SetLogger sets a new slog.Handler
	SetLogger(newHandler slog.Handler)
	// Logger returns the slog.Logger created from the slog.Handler
	Logger() *slog.Logger
}

LoggerSetterGetter is an interface that can set and get a logger

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL