slog

package
v0.0.21-0...-ce50be3 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(name string, opts ...Option) *slog.Logger

func WithLevel

func WithLevel(front slog.Leveler, back slog.Handler) slog.Handler

Types

type LevelHandler

type LevelHandler struct {
	// Level reports the minimum record level that will be logged.
	// The handler discards records with lower levels.
	// If Level is nil, the handler assumes LevelInfo.
	// The handler calls Level.Level for each record processed;
	// to adjust the minimum level dynamically, use a LevelVar.
	Level slog.Leveler
	// Underlying slog.Handler
	slog.Handler
}

func (LevelHandler) Enabled

func (lh LevelHandler) Enabled(ctx context.Context, v slog.Level) bool

Enabled reports whether the handler handles records at the given level. The handler ignores records whose level is lower. It is called early, before any arguments are processed, to save effort if the log event should be discarded. If called from a Logger method, the first argument is the context passed to that method, or context.Background() if nil was passed or the method does not take a context. The context is passed so Enabled can use its values to make a decision.

type Option

type Option = otelslog.Option

Jump to

Keyboard shortcuts

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