log

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GORMLogger

func GORMLogger(l Logger) gormlogger.Interface

GORMLogger adapts a chok Logger to gorm/logger.Interface.

func WithContext

func WithContext(ctx context.Context, l Logger) context.Context

WithContext stores a Logger in ctx. Typically called by HTTP middleware to inject a per-request logger enriched with request_id and other request-scoped attributes.

Types

type Logger

type Logger interface {
	Debug(msg string, keysAndValues ...any)
	Info(msg string, keysAndValues ...any)
	Warn(msg string, keysAndValues ...any)
	Error(msg string, keysAndValues ...any)
	DebugContext(ctx context.Context, msg string, keysAndValues ...any)
	InfoContext(ctx context.Context, msg string, keysAndValues ...any)
	WarnContext(ctx context.Context, msg string, keysAndValues ...any)
	ErrorContext(ctx context.Context, msg string, keysAndValues ...any)
	With(keysAndValues ...any) Logger

	// SetLevel dynamically changes the minimum log level. Accepts
	// "debug" / "info" / "warn" / "warning" / "error". Returns an error
	// for unsupported values. Loggers that don't support dynamic levels
	// (e.g. Empty) may treat this as a no-op.
	SetLevel(level string) error
}

Logger is the framework's logging interface.

func Empty

func Empty() Logger

Empty returns a no-op Logger (for testing).

func FromContext

func FromContext(ctx context.Context) Logger

FromContext retrieves the Logger stored in ctx by WithContext. Returns nil if no logger is present — callers should fall back to a default logger when nil is returned.

func NewDefaultSlog

func NewDefaultSlog() Logger

NewDefaultSlog creates a JSON/info Logger writing to stdout.

func NewSlog

func NewSlog(opts *config.SlogOptions) Logger

NewSlog creates a Logger from SlogOptions.

Jump to

Keyboard shortcuts

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