logger

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: BSD-3-Clause-Clear Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelTrace = slog.Level(-8)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Level  string `mapstructure:"level" json:"level" default:"info"`
	Output string `mapstructure:"output" json:"output" default:"stdout"`
	Type   string `mapstructure:"type" json:"type" default:"json"`
}

type ContextHandler added in v0.7.0

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

ContextHandler is a custom slog.Handler that adds context attributes to log records from values set to the context by the RPC interceptor. It is used to enrich log records with request-specific metadata such as request ID, user agent, request IP, and actor ID.

func (*ContextHandler) Enabled added in v0.7.0

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

func (*ContextHandler) Handle added in v0.7.0

func (h *ContextHandler) Handle(ctx context.Context, r slog.Record) error

Handle overrides the default Handle method to add context values set by RPC interceptor.

func (*ContextHandler) WithAttrs added in v0.7.0

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

func (*ContextHandler) WithGroup added in v0.7.0

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

type Logger

type Logger struct {
	*slog.Logger
	Audit *audit.Logger
}

func CreateTestLogger

func CreateTestLogger() *Logger

func NewLogger

func NewLogger(config Config) (*Logger, error)

func (*Logger) Trace

func (l *Logger) Trace(msg string, args ...any)

func (*Logger) TraceContext

func (l *Logger) TraceContext(ctx context.Context, msg string, args ...any)

func (*Logger) With

func (l *Logger) With(key string, value string) *Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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