logging

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FatalError

func FatalError(log *slog.Logger, message string, err error)

FatalError emits a log at the error level and causes the application to exit

func LogFromContext

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

LogFromContext returns the Logger associated with the context Alternatively, returns the default logger

func LogToContext

func LogToContext(ctx context.Context, log *slog.Logger) context.Context

LogToContext returns a copy of the context with a slog logger attached

func SlogHandler

func SlogHandler(logAsJSON bool, level slog.Leveler, dest io.Writer) slog.Handler

Types

type LogFanoutHandler

type LogFanoutHandler []slog.Handler

LogFanoutHandler is a slog.Handler that sends logs to multiple destinations

func (LogFanoutHandler) Enabled

func (h LogFanoutHandler) Enabled(ctx context.Context, l slog.Level) bool

Implements slog.Handler

func (LogFanoutHandler) Handle

func (h LogFanoutHandler) Handle(ctx context.Context, r slog.Record) error

Implements slog.Handler

func (LogFanoutHandler) WithAttrs

func (h LogFanoutHandler) WithAttrs(attrs []slog.Attr) slog.Handler

Implements slog.Handler

func (LogFanoutHandler) WithGroup

func (h LogFanoutHandler) WithGroup(name string) slog.Handler

Implements slog.Handler

Jump to

Keyboard shortcuts

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