slogger

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package slogger provides a shared LOG_LEVEL-aware slog initialization helper.

Call Init() at the start of any service's main() to configure the global slog logger based on the LOG_LEVEL environment variable. This also bridges legacy log.Print* calls through slog (Go 1.22+ behaviour via slog.SetDefault).

Valid LOG_LEVEL values: "debug", "info", "warn", "error". Default: "info".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

Init reads the LOG_LEVEL environment variable, configures a global slog TextHandler on stdout, and sets it as the default logger. Legacy log.Print* calls are automatically routed through this handler (Go 1.22+).

func IsDebug

func IsDebug() bool

IsDebug returns true when the current log level is debug or lower.

func Level

func Level() slog.Level

Level returns the current slog.Level. Useful for conditional logic such as skipping expensive debug formatting when not in debug mode.

Types

This section is empty.

Jump to

Keyboard shortcuts

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