log

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package log contains utility functions around Go slog package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(err error) slog.Attr

Error returns an slog.Attr for an [error]

func FromContext

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

FromContext retrieves logger from the given context. If no logger is associated with the given context it will return value from slog.Default.

func NewJSONTraceIDHandler

func NewJSONTraceIDHandler(w io.Writer, opts *slog.HandlerOptions) slog.Handler

NewJSONTraceIDHandler creates new slog.JSONHandler which adds a `TraceID` attribute to all loggings if trace id is present.

func WithLogger

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

WithLogger returns a context containing a reference to the given logger

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳