logging

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareAccessLogMiddleware

func PrepareAccessLogMiddleware(serverLogger *slog.Logger) func(next http.Handler) http.Handler

PrepareAccessLogMiddleware builds a logging middleware instance using the provided logger

func RecoveryMiddleware

func RecoveryMiddleware(next http.Handler) http.Handler

RecoveryMiddleware is a middleware that recovers from any panics and returns a consistent error response.

Types

type LogMetadata

type LogMetadata struct {
	Action string
	// User is the authenticated principal (username or access key) or "anonymous".
	// Written by the auth middleware; empty for unauthenticated internal endpoints.
	User string
	// AuthzDecision is "allow" or "deny", written by the authorization middleware.
	// Empty for routes that bypass authorization (health, metrics, etc.).
	AuthzDecision string
	Custom        map[string]string
}

LogMetadata is a mutable metadata container shared between the access log middleware and the inner middleware/handlers via a pointer in context. Inner layers write to it; the access log reads it after the request finishes.

func GetLogData

func GetLogData(ctx context.Context) (*LogMetadata, bool)

Jump to

Keyboard shortcuts

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