log

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: Unlicense Imports: 14 Imported by: 0

Documentation

Overview

Package log provides structured logging with automatic trace correlation. It integrates slog with OpenTelemetry for unified observability.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Debug logs a message at DEBUG level with optional attributes.
	Debug logWithContext = noopLogWithContext
	// Info logs a message at INFO level with optional attributes.
	Info logWithContext = noopLogWithContext
	// Warn logs a message at WARN level with optional attributes.
	Warn logWithContext = noopLogWithContext
	// Error logs an error at ERROR level with stack trace and optional attributes.
	Error func(ctx context.Context, err error, attributes ...attribute.Attr) = func(ctx context.Context, err error, attributes ...attribute.Attr) {}
)

Functions

func InitLogger

func InitLogger(ctx context.Context, resourceAttrs []attribute.Attr, handler ...slog.Handler) (func(context.Context) error, error)

InitLogger initializes structured logging with optional OTEL export. It sets up the package-level Debug, Info, Warn, and Error functions. Logs automatically include trace_id when within a valid trace context.

func NewJSONHandler

func NewJSONHandler(w io.Writer, resourceAttrs []attribute.Attr, logLevel string) (slog.Handler, error)

NewJSONHandler creates a JSON slog handler with resource attributes baked in.

Types

This section is empty.

Jump to

Keyboard shortcuts

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