slog

package
v8.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ReplaceAttrFn = func(groups []string, a slog.Attr) slog.Attr {
	if a.Key == slog.LevelKey {
		level := log.Level(a.Value.Any().(slog.Level))
		a.Value = slog.StringValue(level.String())
	}
	return a
}

ReplaceAttrFn can be used with slog.HandlerOptions to replace attributes. This function replaces the "level" attribute to get the custom log levels of this package.

Functions

This section is empty.

Types

type Handler

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

Handler implementation.

func New

func New(handler slog.Handler) *Handler

New handler wraps an slog.Handler for log output.

Calling this function automatically calls the slog.RedirectGoStdLog function in order to intercept and forward the Go standard library log output to this handler.

func (*Handler) Log

func (h *Handler) Log(e log.Entry)

Log handles the log entry

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳