logger

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logger provides functions for working with structured logging via context.Context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

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

FromContext attempts to return a slog.Logger stored within the provided context.Context. Returns slog.Default if the context does not contain a logger.

func LevelFromString

func LevelFromString(level string) slog.Level

LevelFromString converts a provided string into its corresponding slog.Level. Returns slog.LevelInfo for an invalid string.

func Middleware

func Middleware(logger *slog.Logger) server.Middleware

Middleware is a server.Middleware implementation that ensures each inbound HTTP request's context contains the slog.Logger.

func ToContext

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

ToContext adds the provided slog.Logger to the given context.Context and returns it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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