handler

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Opts Opts
}

func (*Handler) Enabled

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

Enabled reports whether the given level is enabled by cfg.Level.

func (*Handler) Handle

func (h *Handler) Handle(_ context.Context, r slog.Record) error

Handle formats the record as a and writes it to stdout. Output includes timestamp, level, message, attrs, and optional caller info. The context is ignored.

func (*Handler) WithAttrs

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

WithAttrs returns h unchanged

func (*Handler) WithGroup

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

WithGroup returns h unchanged

type Opts

type Opts interface {
	// GetLevel returns the minimum log level for output.
	GetLevel() slog.Level

	// IsCallerEnabled checks if caller information should be included for the given level.
	IsCallerEnabled(level slog.Level) bool

	// GetPadding returns the amount of padding to apply in log messages.
	GetPadding() int
}

Opts defines the interface for retrieving handler configuration settings.

Jump to

Keyboard shortcuts

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