log

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 6 Imported by: 20

Documentation

Index

Constants

View Source
const (
	LoggerNameContextKey domain.ContextKey = "LoggerNameContextKey"
)

Variables

View Source
var (
	DefaultLogger   *slog.Logger
	DefaultLogLevel slog.Level
	LogHandlers     map[slog.Level]slog.Handler        = make(map[slog.Level]slog.Handler)
	Loggers         map[domain.ContextKey]*slog.Logger = make(map[domain.ContextKey]*slog.Logger)
)
View Source
var (
	LoggerNameKey = "logger_name"
)

Functions

func GetLoggerFromContext

func GetLoggerFromContext(ctx context.Context, key domain.ContextKey) *slog.Logger

GetLoggerFromContext Gets the logger from context

func WithLoggerName

func WithLoggerName(ctx context.Context, val domain.ContextKey) context.Context

Types

type LogHandler

type LogHandler struct {
	slog.Handler
}

func (*LogHandler) Handle

func (h *LogHandler) Handle(ctx context.Context, record slog.Record) error

func (*LogHandler) WithAttrs

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

func (*LogHandler) WithGroup

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

Jump to

Keyboard shortcuts

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