logfmt

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler 以 logfmt 形式输出,便于 Loki/Vector 等收集器解析。

func New

func New(opt Option) *Handler

New 创建 Handler。

func (*Handler) Enabled

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

func (*Handler) Handle

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

func (*Handler) WithAttrs

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

func (*Handler) WithGroup

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

type Option

type Option struct {
	Writer      modules.WriteSyncer
	Level       slog.Leveler
	AddSource   bool
	TimeFormat  string
	ReplaceAttr func(groups []string, a slog.Attr) slog.Attr
}

Option 用于创建 Handler。

Jump to

Keyboard shortcuts

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