log

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MPL-2.0 Imports: 7 Imported by: 17

Documentation

Overview

Copied from https://pkg.go.dev/log/slog#Handler

Package log is a context wrapper around slog.Logger

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, msg string, attrs ...slog.Attr)

func Error

func Error(ctx context.Context, msg string, attrs ...slog.Attr)

func Info

func Info(ctx context.Context, msg string, attrs ...slog.Attr)

func Init added in v0.6.2

func Init()

func Leveled

func Leveled(ctx context.Context, level slog.Level) context.Context

func Warn

func Warn(ctx context.Context, msg string, attrs ...slog.Attr)

func With

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

func WithDefault added in v0.6.8

func WithDefault(ctx context.Context) context.Context

func WithTB

func WithTB(ctx context.Context, tb testing.TB) context.Context

Types

type LevelHandler added in v0.6.8

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

A LevelHandler wraps a Handler with an Enabled method that returns false for levels below a minimum.

func NewLevelHandler added in v0.6.8

func NewLevelHandler(level slog.Leveler, h slog.Handler) *LevelHandler

NewLevelHandler returns a LevelHandler with the given level. All methods except Enabled delegate to h.

func (*LevelHandler) Enabled added in v0.6.8

func (h *LevelHandler) Enabled(_ context.Context, level slog.Level) bool

Enabled implements Handler.Enabled by reporting whether level is at least as large as h's level.

func (*LevelHandler) Handle added in v0.6.8

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

Handle implements Handler.Handle.

func (*LevelHandler) Handler added in v0.6.8

func (h *LevelHandler) Handler() slog.Handler

Handler returns the Handler wrapped by h.

func (*LevelHandler) WithAttrs added in v0.6.8

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

WithAttrs implements Handler.WithAttrs.

func (*LevelHandler) WithGroup added in v0.6.8

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

WithGroup implements Handler.WithGroup.

type PrettyHandler added in v0.6.8

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

func NewPrettyHandler added in v0.6.8

func NewPrettyHandler(h slog.Handler) *PrettyHandler

func (*PrettyHandler) Enabled added in v0.6.8

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

func (*PrettyHandler) Handle added in v0.6.8

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

func (*PrettyHandler) WithAttrs added in v0.6.8

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

func (*PrettyHandler) WithGroup added in v0.6.8

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

Jump to

Keyboard shortcuts

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