Documentation
¶
Overview ¶
Package logging configures the agent's structured logger.
The package wraps stdlib log/slog: a Handle owns a slog.LevelVar (atomic, settable at runtime) and a slog.Logger. Init sets that logger as slog.Default so any package can call slog.Info/Warn/Error directly without plumbing the Handle through every constructor.
To change the level at runtime, call Handle.SetLevel. The runtime package wires this to SIGHUP and an HTTP endpoint.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseLevel ¶
ParseLevel parses one of "debug", "info", "warn", "error" (case insensitive) into the corresponding slog.Level. Returns an error for any other value.
Types ¶
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle is the runtime state of the agent's logging configuration. Init returns one and the runtime package uses it to change the level without restarting the agent.
func Init ¶
Init builds a Handle from cfg, writes log records to w, and registers the resulting logger as slog.Default. Returns the Handle so the caller can change the level at runtime via Handle.SetLevel.
Subsequent calls replace the previous logger; mostly useful in tests.
func (*Handle) CurrentLevel ¶
CurrentLevel returns the level currently in effect as a lowercase string (e.g. "info", "debug"). Suitable for inclusion in /debug responses.