logging

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package logging provides context-aware structured logging wrapping log/slog.

In production mode a JSON handler is used; in development mode a coloured tint handler makes output easy to scan. Loggers are threaded through context.Context so that request-scoped attributes propagate automatically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

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

FromContext extracts the logger stored in ctx. If no logger is found the package-level default logger is returned.

func New

func New(production bool) *slog.Logger

New creates a new *slog.Logger. When production is true a JSON handler writing to stdout is used; otherwise a tint handler with coloured output and timestamps is returned.

func With

func With(ctx context.Context, args ...any) context.Context

With returns a copy of ctx whose logger has the supplied slog attributes appended. If ctx does not carry a logger the default logger is used.

func WithLogger

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

WithLogger returns a copy of ctx carrying l.

Types

This section is empty.

Jump to

Keyboard shortcuts

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