logger

package
v1.28.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = slog.Default()

Functions

func NewHandler added in v1.28.0

func NewHandler(options ...Option) (handler slog.Handler)

Types

type Handler added in v1.28.0

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

func (*Handler) Enabled added in v1.28.0

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

func (*Handler) Handle added in v1.28.0

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

func (*Handler) WithAttrs added in v1.28.0

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

func (*Handler) WithGroup added in v1.28.0

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

type Option added in v1.28.0

type Option func(*handlerOpts)

func Delimiter added in v1.28.0

func Delimiter(delimiter string) Option

Delimiter sets the delimiter between attributes in the output. The default is a single dot.

func JSON added in v1.28.0

func JSON() Option

JSON configures the handler to output JSON instead of a human-readable format.

func Leveler added in v1.28.0

func Leveler(level *slog.LevelVar) Option

Leveler sets the log level for the handler using a slog.Leveler. This allows the log level to be changed at runtime. The default is slog.LevelInfo.

func SourceTrimTo added in v1.28.0

func SourceTrimTo(anchor string) Option

SourceTrimTo sets the directory in the source path to trim up to, including a tailing '/'. e.g. if the source path is "/home/user/project/pkg/file.go" and the anchor is "project", the resulting source path in the log will be "pkg/file.go".

func TimeFormat added in v1.28.0

func TimeFormat(format string) Option

TimeFormat sets the time format for time attributes. The default is "2006-01-02T15:04:05.000Z07:00". The format should be a valid Go time format string.

func Writer added in v1.28.0

func Writer(w io.Writer) Option

Writer sets the output writer for the handler. The default is os.Stderr.

Jump to

Keyboard shortcuts

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