slogutil

package
v0.72.7 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttrsFromAny added in v0.64.11

func AttrsFromAny(args ...any) []slog.Attr

func ContextWithLogger added in v0.72.5

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

ContextWithLogger returns a new context with the given logger attached. Use this to pass request-scoped loggers (with trace IDs, user IDs, etc.) that will be used for logging within that request.

func Discard added in v0.72.1

func Discard() *slog.Logger

Discard is an expensive nop logger using the stdlib.

func LogOrNot

func LogOrNot(ctx context.Context, logger *slog.Logger, level slog.Level, msg string, attrs ...slog.Attr)

func LogOrNotAny added in v0.64.11

func LogOrNotAny(ctx context.Context, logger *slog.Logger, level slog.Level, msg string, args ...any)

func LoggerFromContext added in v0.72.5

func LoggerFromContext(ctx context.Context, fallback *slog.Logger) *slog.Logger

LoggerFromContext returns the logger from context if present, otherwise returns the fallback logger.

func Null added in v0.72.1

func Null() *slog.Logger

Null is an inexpensive nop logger.

Types

type NullHandler added in v0.72.1

type NullHandler struct{}

func (NullHandler) Enabled added in v0.72.1

func (NullHandler) Enabled(_ context.Context, _ slog.Level) bool

func (NullHandler) Handle added in v0.72.1

func (NullHandler) Handle(_ context.Context, _ slog.Record) error

func (NullHandler) WithAttrs added in v0.72.1

func (h NullHandler) WithAttrs(_ []slog.Attr) slog.Handler

func (NullHandler) WithGroup added in v0.72.1

func (h NullHandler) WithGroup(_ string) slog.Handler

Jump to

Keyboard shortcuts

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