log

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package log provides structured logging utilities.

Package log provides structured logging utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base

func Base() zerolog.Logger

Base returns the configured base logger instance.

func Configure

func Configure(cfg Config)

Configure initialises the global zerolog logger.

func ContextWithJobID

func ContextWithJobID(ctx context.Context, id string) context.Context

ContextWithJobID stores the provided job ID in the context.

func ContextWithRequestID

func ContextWithRequestID(ctx context.Context, id string) context.Context

ContextWithRequestID stores the provided request ID in the context.

func Derive

func Derive(build func(*zerolog.Context)) zerolog.Logger

Derive attaches arbitrary fields to a child logger using the provided builder function.

func FromContext

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

FromContext returns a logger from the context, or a new one if not present.

func JobIDFromContext

func JobIDFromContext(ctx context.Context) string

JobIDFromContext extracts the job ID from context if present.

func L

func L() *zerolog.Logger

L provides access to the global logger instance.

func Middleware

func Middleware() func(http.Handler) http.Handler

Middleware returns a new http.Handler middleware that logs requests using zerolog.

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext extracts the request ID from context if present.

func WithComponent

func WithComponent(component string) zerolog.Logger

WithComponent returns a child logger annotated with the given component name.

func WithComponentFromContext

func WithComponentFromContext(ctx context.Context, component string) zerolog.Logger

WithComponentFromContext returns a logger that is annotated with the component name and enriched with correlation fields from ctx.

func WithContext

func WithContext(ctx context.Context, logger zerolog.Logger) zerolog.Logger

WithContext enriches the supplied logger with correlation fields from context.

Types

type Config

type Config struct {
	Level   string    // optional log level ("debug", "info", etc.)
	Output  io.Writer // optional writer (defaults to os.Stdout)
	Service string    // optional service name attached to every log entry
}

Config captures options for configuring the global logger.

Jump to

Keyboard shortcuts

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