sloghelper

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 3 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorKey = "error"

Functions

func Error

func Error(err error) slog.Attr

func ErrorValue

func ErrorValue(err error) slog.Value

func FromContext

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

func NewContext

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

func NewHandler

func NewHandler(hdl slog.Handler, opts ...HandlerOption) slog.Handler

Types

type HandleFunc

type HandleFunc func(context.Context, *slog.Record)

type Handler

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

func (*Handler) Apply

func (ch *Handler) Apply(opt HandlerOption)

func (*Handler) Enabled

func (ch *Handler) Enabled(ctx context.Context, level slog.Level) bool

func (*Handler) Handle

func (ch *Handler) Handle(ctx context.Context, r slog.Record) error

func (*Handler) WithAttrs

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

func (*Handler) WithGroup

func (ch *Handler) WithGroup(name string) slog.Handler

type HandlerOption

type HandlerOption func(*Handler)

func WithDisableStackTrace added in v0.3.1

func WithDisableStackTrace(disabled bool) HandlerOption

func WithHandleFunc

func WithHandleFunc(fn HandleFunc) HandlerOption

func WithStackKey added in v0.3.1

func WithStackKey(key string) HandlerOption

Jump to

Keyboard shortcuts

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