logging

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package logging provides logging utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

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

Extract will extract a logger from the context. If no logger is found, a default logger with level info is returned.

func Inject

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

Inject will inject a logger into the context.

func InjectLabels

func InjectLabels(ctx context.Context, labels ...any) (context.Context, *slog.Logger)

InjectLabels injects labels to the logger living in the context, it will return both the context and the logger.

func NewJSON

func NewJSON(requestedLevel string, humanReadable bool) *slog.Logger

New will initialise a new structured logger with JSON output, logging at the desired level. If the requested level doesn't exist, it panics.

func NewMiddleware

func NewMiddleware(logger *slog.Logger) func(http.Handler) http.Handler

NewMiddleware creates a middleware function that injects the logger into the context of the request, including some useful tags.

Types

This section is empty.

Jump to

Keyboard shortcuts

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