logger

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: BSD-3-Clause-Clear Imports: 10 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"`
	// TraceCorrelation adds the active trace and span IDs to log and audit
	// records. No-op unless tracing is enabled via `server.trace`. Nil means enabled.
	TraceCorrelation *bool `mapstructure:"trace_correlation" json:"trace_correlation" default:"true"`
	// AuditTimeout is the audit processing budget. Non-positive values use five seconds.
	AuditTimeout time.Duration `mapstructure:"audit_timeout" json:"audit_timeout" yaml:"audit_timeout" default:"5s"`
	// AuditProcessor overrides audit delivery for Go callers and is never serialized.
	AuditProcessor audit.Processor `mapstructure:"-" json:"-" yaml:"-"`
	// ContextAttrs derive attributes from each record's context. Go callers only.
	ContextAttrs []ContextAttrFunc `mapstructure:"-" json:"-" yaml:"-"`
}

type ContextAttrFunc added in v0.27.0

type ContextAttrFunc func(context.Context) []slog.Attr

ContextAttrFunc derives log attributes from a record's context. It returns nil when the context carries nothing to add.

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) LogPolicyCRUDFailure added in v0.28.0

func (l *Logger) LogPolicyCRUDFailure(ctx context.Context, params audit.PolicyEventParams)

LogPolicyCRUDFailure records a failed policy operation and logs any audit error.

func (*Logger) LogPolicyCRUDSuccess added in v0.28.0

func (l *Logger) LogPolicyCRUDSuccess(ctx context.Context, params audit.PolicyEventParams)

LogPolicyCRUDSuccess records a successful policy operation and logs any audit 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