Documentation ¶
Overview ¶
Package logger implements a log/slog based logger in Zarf.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Debug = Level(slog.LevelDebug) // -4 Info = Level(slog.LevelInfo) // 0 Warn = Level(slog.LevelWarn) // 4 Error = Level(slog.LevelError) // 8 )
Store names for Levels
Functions ¶
func Default ¶
Default retrieves a logger from the package default. This is intended as a fallback when a logger cannot easily be passed in as a dependency, like when developing a new function. Use it like you would use context.TODO().
func SetDefault ¶
SetDefault takes a logger and atomically stores it as the package default. This is intended to be called when the application starts to override the default config with application-specific config. See Default() for more usage details.
Types ¶
type Config ¶
type Config struct { // Level sets the log level. An empty value corresponds to Info aka 0. Level Format Destination }
Config is configuration for a logger.
func ConfigDefault ¶
func ConfigDefault() Config
ConfigDefault returns a Config with defaults like Text formatting at Info level writing to Stderr.
type Destination ¶
Destination declares an io.Writer to send logs to.
var ( // DestinationDefault points to Stderr DestinationDefault Destination = os.Stderr // DestinationNone discards logs as they are received DestinationNone Destination = io.Discard )
type Format ¶
type Format string
Format declares the kind of logging handler to use. An empty Format defaults to text.
type Level ¶
type Level int
Level declares each supported log level. These are 1:1 what log/slog supports by default. Info is the default level.
func ParseLevel ¶
ParseLevel takes a string representation of a Level, ensure it exists, and then converts it into a Level.