logging

package
v3.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package logging builds slog loggers and carries one on a context, so app and library code log through a per-invocation logger instead of the process-global slog default. The CLI configures one logger per command Execute (respecting --verbose/--quiet and the command's stderr) and threads it through the context the app and pkg layers already receive; no code mutates slog's default.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggerFromContext

func LoggerFromContext(ctx context.Context) *slog.Logger

LoggerFromContext returns the logger carried by ctx, or slog.Default() when none is present (library callers that never set one, tests, the operator). It never returns nil. slog.Default() is only ever read here, never replaced, so concurrent callers do not race on a process global.

func New

func New(w io.Writer, verbose bool) *slog.Logger

New returns a text logger writing to w. When verbose is true it emits Debug and above; otherwise Warn and above, which silences informational output.

func WithLogger

func WithLogger(ctx context.Context, l *slog.Logger) context.Context

WithLogger returns ctx carrying l for retrieval by LoggerFromContext.

Types

This section is empty.

Jump to

Keyboard shortcuts

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