logger

package
v0.1.26 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProjectID = "project_id"
	RequestID = "request_id"
)

Variables

This section is empty.

Functions

func Error

func Error(err error) slog.Attr

Error returns an attribute for an error string value.

func New

func New(name string) *slog.Logger

New creates a new standard logger with a context handler.

Types

type ContextHandler

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

ContextHandler is a logger handler that adds context attributes to log records.

func NewContextHandler

func NewContextHandler(name string, baseHandler slog.Handler) *ContextHandler

NewContextHandler creates a new context handler.

func (*ContextHandler) Enabled

func (c *ContextHandler) Enabled(ctx context.Context, level slog.Level) bool

Enabled wraps the base handler's Enabled method.

func (*ContextHandler) Handle

func (c *ContextHandler) Handle(ctx context.Context, record slog.Record) error

Handle warps the base handler's Handle method and adds context attributes to the log record.

func (*ContextHandler) WithAttrs

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

WithAttrs wraps the base handler's WithAttrs method.

func (*ContextHandler) WithGroup

func (c *ContextHandler) WithGroup(name string) slog.Handler

WithGroup wraps the base handler's WithGroup method.

Jump to

Keyboard shortcuts

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