Documentation
¶
Overview ¶
Package logger configures native slog with recursive structured-field redaction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDefault ¶ added in v1.1.0
func SetDefault(l *Logger)
SetDefault installs l as the process default logger.
Types ¶
type Config ¶
type Config struct {
JSON bool
Level slog.Level
Output io.Writer
OwnOutput bool
File string
MaxSizeMB, MaxBackups, MaxAgeDays int
Compress bool
Service, Version, Environment, TimeFormat string
SanitizeText func(string) string
}
Config contains explicit constructor settings; see package documentation for defaults.
type Level ¶ added in v1.1.0
Level is the standard logging threshold exposed without requiring consumers to import slog directly.
func ParseLevel ¶ added in v1.1.0
ParseLevel parses a textual level and falls back to Info when invalid.
type Logger ¶
Logger embeds native slog and owns applicable configured outputs.
func Default ¶ added in v1.1.0
func Default() *Logger
Default returns a wrapper around the process default logger.
func New ¶
New constructs and validates an explicitly owned instance. See package documentation for defaults and cleanup.
func Open ¶
Open validates output settings and eagerly checks file access. New remains available for callers that deliberately use slog's lazy write error handling.
func (*Logger) Close ¶
Close releases owned resources. See package documentation for shutdown ordering.
func (*Logger) Flush ¶
Flush invokes a configured writer's flush contract. Injected writers remain caller-owned unless OwnOutput is explicitly enabled. Call after producers stop.
func (*Logger) WithContext ¶
WithContext copies logger correlation attributes from the supplied context.