logging

package
v0.0.0-...-dac93a9 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default

func Default() *slog.Logger

Default returns the default logger for backward compatibility

func DeleteGoroutineLogger

func DeleteGoroutineLogger(gid uint64)

func From

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

from returns the request scoped logger if present, else the global default

func GetBaseLogger

func GetBaseLogger() *slog.Logger

GetBaseLogger returns the base logger for use in middleware (avoids loops)

func GetGoroutineID

func GetGoroutineID() uint64

func InheritRequestLogger

func InheritRequestLogger(ctx context.Context) (cleanup func())

Add this helper function:

func Init

func Init() *slog.Logger

sets up the process wide base logger with automatic context detection

func Inject

func Inject(ctx context.Context, l *slog.Logger) context.Context

inject stores a logger in ctx

func Middleware

func Middleware() gin.HandlerFunc

func StoreGoroutineLogger

func StoreGoroutineLogger(gid uint64, logger *slog.Logger)

Helper functions for middleware to access the goroutine map

Types

type SentryHandler

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

SentryHandler wraps any slog.Handler and automatically sends ERROR and WARN logs to Sentry

func NewSentryHandler

func NewSentryHandler(next slog.Handler) *SentryHandler

NewSentryHandler creates a new SentryHandler that wraps the given 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, record 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

Jump to

Keyboard shortcuts

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