contextlogger

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAttributes

func BuildAttributes(ctx context.Context, r *http.Request, extractFunc func(ctx context.Context, r *http.Request) map[string]interface{}) []interface{}

func DefaultExtractor

func DefaultExtractor(ctx context.Context, r *http.Request) map[string]interface{}

DefaultExtractor extracts operation request fields from the context. It returns the filtered map containing only the specified keys.

func GetLogger

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

func New

func New(logger slog.Logger, extractFunction ExtractFunction) mux.MiddlewareFunc

New creates a context logging middleware. Parameters

logger:                  A slog.Logger instance used for logging. Any static attributes added to this logger before passing it in will be preserved
extractFunction:         ExtractFunction extracts information from the ctx and/or the request and put it in the logger

Types

type ExtractFunction

type ExtractFunction func(ctx context.Context, r *http.Request) map[string]interface{}

Jump to

Keyboard shortcuts

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