slogcontexthandler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package slogcontexthandler provides a slog.Handler that adds attributes from the log's context.Context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAttrs

func AddAttrs(ctx context.Context, attrs ...slog.Attr) context.Context

AddAttrs adds attributes to a context.Context.

The attributes will be merged with any existing attributes on the context.

Any new attribute with the same key as an existing attribute will replace the existing attribute.

func GetAttrs

func GetAttrs(ctx context.Context) []slog.Attr

GetAttrs returns the attributes set on a context.Context, if any.

func New

func New(handler slog.Handler) slog.Handler

New returns a slog.Handler that adds attributes from the log's context.Context.

All other methods are just delegated to the wrapped slog.Handler.

func SetAttrs

func SetAttrs(ctx context.Context, attrs ...slog.Attr) context.Context

SetAttrs sets the attributes on a context.Context.

Unlike AddAttrs, SetAttrs does not deduplicate or merge the new attributes with existing attributes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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