package
Version:
v0.1.3
Opens a new window with list of versions in this module.
Published: Oct 1, 2026
License: MIT
Opens a new window with license information.
Imports: 7
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package logger provides structured logging with slog, tint-based human-readable
output, and OpenTelemetry trace correlation.
-
func Debug(ctx context.Context, msg string, args ...any)
-
func Error(ctx context.Context, msg string, args ...any)
-
func FromContext(ctx context.Context) *slog.Logger
-
func Info(ctx context.Context, msg string, args ...any)
-
func New(cfg Config, opts ...Option) *slog.Logger
-
func Warn(ctx context.Context, msg string, args ...any)
-
func WithContext(ctx context.Context, logger *slog.Logger) context.Context
-
type Config
-
type Option
Debug logs at LevelDebug using the logger from context.
Error logs at LevelError using the logger from context.
FromContext extracts the logger from context or returns the default logger.
Info logs at LevelInfo using the logger from context.
New creates a configured slog.Logger instance based on Config and Options.
Warn logs at LevelWarn using the logger from context.
WithContext returns a new context carrying the given logger.
type Config struct {
Format string `toml:"format" env:"FORMAT" env-default:"text" comment:"Log format: text or json"`
Level string `toml:"level" env:"LEVEL" env-default:"info" comment:"Log level: debug, info, warn, error"`
}
Config defines logger configuration settings.
Option decorates the base slog.Handler.
WithTracing returns an Option that injects trace_id and span_id into log records.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.