logging

package
v0.0.0-...-6ed2b60 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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

func ParseLevel(s string) (slog.Level, error)

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

func Init(cfg config.LoggingConfig, w io.Writer) (*Handle, error)

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

func (h *Handle) CurrentLevel() string

CurrentLevel returns the level currently in effect as a lowercase string (e.g. "info", "debug"). Suitable for inclusion in /debug responses.

func (*Handle) Logger

func (h *Handle) Logger() *slog.Logger

Logger returns the slog.Logger associated with this handle. Identical to slog.Default unless Init has been called again since.

func (*Handle) SetLevel

func (h *Handle) SetLevel(s string) error

SetLevel atomically updates the minimum level the logger emits. Safe to call concurrently with active log calls; backed by slog.LevelVar.

Jump to

Keyboard shortcuts

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