logging

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error added in v0.0.9

func Error(err error) slog.Attr

func NewLogger added in v0.0.9

func NewLogger(opts ...LoggingOptions) *slog.Logger

func NewNullLogger added in v0.0.11

func NewNullLogger() *slog.Logger

Types

type LoggingOptions added in v0.0.16

type LoggingOptions struct {
	// Filepath | "" or "stderr" for stderr | "stdout" for stdout (default "")
	Target string
	// adds a "2006_01_02_15_04_05" timestamp to the log file name
	// Not compatible with stderr/stdout (default false)
	PrefixFilenameWithTime bool
	// Whether to add the source location of the call to log (default false)
	AddSource bool
	// Minimum level to log for this handler (default INFO)
	Level slog.Level
	// false means TextHandler, true means JsonHandler
	// overridden by CustomHandler (default false)
	JsonHandler bool
	// ReplaceAttrs are called to rewrite each attribute before it is logged. (default nil)
	ReplaceAttrs []func(attrGroups []string, a slog.Attr) slog.Attr
	// Your custom handler, overrides all other fields (default nil)
	CustomHandler slog.Handler
}

LoggingOptions describes a handler

func (LoggingOptions) Handler added in v0.0.16

func (o LoggingOptions) Handler() slog.Handler

Handler instantiates a new handle based on the requested options

type NullHandler added in v0.0.11

type NullHandler sets.Unit

func (NullHandler) Enabled added in v0.0.11

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

func (NullHandler) Handle added in v0.0.11

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

func (NullHandler) WithAttrs added in v0.0.11

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

func (NullHandler) WithGroup added in v0.0.11

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

type TeeHandler added in v0.0.9

type TeeHandler struct {
	Handlers []slog.Handler
}

func NewTeeHandler added in v0.0.9

func NewTeeHandler(handlers ...slog.Handler) *TeeHandler

func (*TeeHandler) Enabled added in v0.0.9

func (h *TeeHandler) Enabled(ctx context.Context, lvl slog.Level) bool

func (*TeeHandler) Handle added in v0.0.9

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

func (*TeeHandler) WithAttrs added in v0.0.9

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

func (*TeeHandler) WithGroup added in v0.0.9

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

Jump to

Keyboard shortcuts

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