logger

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logger provides structured JSON logging via log/slog with level-based stdout/stderr routing and context propagation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogger

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

GetLogger returns the central singleton logger. ctx is the reserved correlation seam (per-context attributes ride it the day chinit grows request-scoped logging); nil is accepted and reads as context.Background(). The singleton is never nil: package init installs the default handler.

func Init

func Init()

Init installs the process-wide singleton over the REAL stdout and stderr (JSON records, level-split). Idempotent and re-callable: Main installs it at entry, and specs re-call it to restore the default after SetLogHandler swaps in a capture buffer.

func IsDebugEnabled

func IsDebugEnabled() bool

IsDebugEnabled reports whether Debug records pass the filter.

func LogLevel

func LogLevel() slog.Level

LogLevel reports the process-wide minimum record level.

func NewLevelSplitHandler

func NewLevelSplitHandler(out, err io.Writer) slog.Handler

NewLevelSplitHandler builds the routing handler over two underlying JSON handlers (info → out, warn+ → err), both at LevelDebug so the route decision and the levelVar are the only filters.

func SetLogHandler

func SetLogHandler(h slog.Handler)

SetLogHandler replaces the singleton's handler — the one configuration seam. The new logger also becomes slog.Default so a stray package-level slog call can never bypass the singleton.

func SetLogLevel

func SetLogLevel(level slog.Level)

SetLogLevel sets the process-wide minimum record level (Debug unlocks the chatty internals the Info default keeps out of the journal).

Types

This section is empty.

Jump to

Keyboard shortcuts

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