logging

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logging provides a structured logger built on log/slog. It is configured once at startup via New and distributed through context values using WithLogger / FromContext.

Environment variables:

LOG_LEVEL  = debug | info | warn | error  (default: info)
LOG_FORMAT = json | text                  (default: json)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

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

FromContext returns the *slog.Logger stored in ctx. If no logger is present it returns slog.Default so callers never need to nil-check.

func New

func New() *slog.Logger

New constructs a *slog.Logger from environment variables. LOG_FORMAT selects the handler (json for production, text for local dev). LOG_LEVEL sets the minimum severity level.

func WithLogger

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

WithLogger returns a copy of ctx carrying logger.

Types

This section is empty.

Jump to

Keyboard shortcuts

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