Documentation ¶ Index ¶ type Handler func New(opt Option) *Handler func (h *Handler) Enabled(_ context.Context, l slog.Level) bool func (h *Handler) Handle(_ context.Context, r slog.Record) error func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler func (h *Handler) WithGroup(name string) slog.Handler type Option 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。 Source Files ¶ View all Source files handler.go Click to show internal directories. Click to hide internal directories.