logger

package
v0.0.0-...-725261d Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package logger provides a preinitialized slog logger ready for use.

Additionally it provides middlewares for use with http handlers to record access logs.

Index

Constants

View Source
const LevelTrace slog.Level = -8
View Source
const MaximumValueLength = 2000

Variables

This section is empty.

Functions

func AccessLogMiddleware

func AccessLogMiddleware(next http.Handler) http.Handler

func ContextWithAttr

func ContextWithAttr(parent context.Context, attr slog.Attr) context.Context

ContextWithAttr returns a copy of parent in which the attr is added to the list of slog attributes attached to the context.

Use context slog attributes only for request-scoped log attributes.

func Err

func Err(err error) slog.Attr

Err is a helper function to ensure errors are always logged with the key "err". Additionally this becomes the single point in code, where we could tweak how errors are logged, e.g. to handle application specific error types or to add stack trace information in debug mode.

func InitLogger

func InitLogger(writer io.Writer, filepath string, verbose bool, debug bool) error

func RequestIDMiddleware

func RequestIDMiddleware(next http.Handler) http.Handler

Types

This section is empty.

Jump to

Keyboard shortcuts

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