log

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package log provides utilities for attaching an slog.Logger configured with request-specific attributes to context.Context. The logger can later be retrieved or used indirectly through package-level logging function calls.

Server and client extension point implementations should use this package for generating logs instead of using other loggers or slog directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(ctx context.Context, msg string, err error, keyValArgs ...any)

Error invokes ErrorContext on the slog.Logger associated with the provided Context or slog.Default() if no context-scoped logger is available.

func Info

func Info(ctx context.Context, msg string, keyValArgs ...any)

Info invokes InfoContext on the slog.Logger associated with the provided Context or slog.Default() if no context-scoped logger is available.

func Log

func Log(ctx context.Context, level slog.Level, msg string, keyValArgs ...any)

Log invokes Log on the slog.Logger associated with the provided Context or slog.Default() if no context-scoped logger is available.

func LoggerFrom

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

LoggerFrom returns the Logger associated with the context, or slog.Default() if no context-scoped logger is available.

func Warn

func Warn(ctx context.Context, msg string, keyValArgs ...any)

Warn invokes WarnContext on the slog.Logger associated with the provided Context or slog.Default() if no context-scoped logger is available.

func WithLogger

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

WithLogger creates a new Context with the provided Logger attached.

Types

This section is empty.

Jump to

Keyboard shortcuts

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