logging

package
v1.1.3 Latest Latest
Warning

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

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

Documentation

Overview

Package logging provides a standardized logger construction for all OpenChoreo components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(component string) *slog.Logger

Bootstrap creates a minimal logger for pre-configuration errors. It writes JSON to stderr and includes the component field. Use this before any configuration is loaded.

func FromContext

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

FromContext retrieves the logger from context. Returns slog.Default() if no logger is found.

func New

func New(cfg Config) *slog.Logger

New creates a configured slog.Logger from the config.

func NewContext

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

NewContext returns a new context with the logger attached.

func NewWithComponent

func NewWithComponent(cfg Config, component string) *slog.Logger

NewWithComponent creates a configured logger with a component field.

Types

type Config

type Config struct {
	// Level is the minimum log level (debug, info, warn, error).
	Level string
	// Format is the log output format (json, text).
	Format string
	// AddSource includes source file and line number in log entries.
	AddSource bool
}

Config defines logging settings.

Jump to

Keyboard shortcuts

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