logging

package
v0.0.0-...-54f4ef6 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package logging provides logging configuration and utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(ctx context.Context, config Config) (*slog.Logger, context.Context)

Configure sets up logging with the given config and returns the logger and updated context.

func ContextWithLogger

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

ContextWithLogger returns a new context with the given logger.

func FromContext

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

func GetLevel

func GetLevel() slog.Level

GetLevel returns the current global log level.

func Middleware

func Middleware(next http.Handler, config Config) http.Handler

Middleware returns an HTTP middleware that logs incoming requests and attaches any configured headers as log attributes.

func SetLevel

func SetLevel(level slog.Level)

SetLevel sets the global log level at runtime.

Types

type Config

type Config struct {
	JSON    bool              `hcl:"json,optional" help:"Enable JSON logging."`
	Level   slog.Level        `hcl:"level" help:"Set the logging level." default:"info"`
	Remap   map[string]string `hcl:"remap,optional" help:"Remap field names from old to new (e.g., msg=message, time=timestamp)."`
	Headers map[string]string `hcl:"headers,optional" help:"Propagate these inbound request headers to the given log attribute."`
}

Jump to

Keyboard shortcuts

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