logging

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BridgeStandardLog

func BridgeStandardLog(handler slog.Handler)

BridgeStandardLog redirects the global standard log package to use the provided slog.Handler.

func NewCronLoggerAdapter

func NewCronLoggerAdapter(logger *slog.Logger, source string) *cronLoggerAdapter

func NewZapLoggerAdapter

func NewZapLoggerAdapter(logger *slog.Logger, source string) *zap.Logger

NewZapLoggerAdapter creates a zap.Logger that writes to the provided slog.Logger.

func ReplaceAttr

func ReplaceAttr(groups []string, a slog.Attr) slog.Attr

ReplaceAttr is a slog.HandlerOptions.ReplaceAttr function that recursively processes attributes to ensure time.Duration and errors are formatted correctly.

Types

type SentryHandler

type SentryHandler struct {
	// contains filtered or unexported fields
}

SentryHandler wraps an existing slog.Handler and forwards logs with a specific level or higher to Sentry.

func NewSentryHandler

func NewSentryHandler(minLevel slog.Level, next slog.Handler) *SentryHandler

NewSentryHandler creates a new SentryHandler that wraps the provided handler.

func (*SentryHandler) Enabled

func (h *SentryHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*SentryHandler) Handle

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

func (*SentryHandler) WithAttrs

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

func (*SentryHandler) WithGroup

func (h *SentryHandler) WithGroup(name string) slog.Handler

type TracingHandler

type TracingHandler struct {
	// contains filtered or unexported fields
}

TracingHandler is a slog.Handler that adds trace_id and span_id to logs if present in the context.

func NewTracingHandler

func NewTracingHandler(next slog.Handler) *TracingHandler

func (*TracingHandler) Enabled

func (h *TracingHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*TracingHandler) Handle

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

func (*TracingHandler) WithAttrs

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

func (*TracingHandler) WithGroup

func (h *TracingHandler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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