logging

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: EUPL-1.2 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Component

func Component(v any) slog.Attr

Component returns a slog attribute for a component type.

func Error

func Error(err error) slog.Attr

Error returns a slog attribute for errors.

func FHIRServer

func FHIRServer(url string) slog.Attr

FHIRServer returns a slog attribute for FHIR server URLs.

func GetLogrusLevel added in v0.10.0

func GetLogrusLevel(level slog.Level) string

GetLogrusLevel converts a slog level to a logrus level string.

func Init

func Init()

Init initializes the global slog logger with JSON output and trace context injection. Default log level is Debug to match previous zerolog configuration.

func InitLogrus added in v0.10.0

func InitLogrus()

InitLogrus configures the global logrus logger to route all log output through slog. This ensures libraries that use logrus (e.g. OPA, nuts-node) participate in the centralized slog pipeline, including OpenTelemetry export.

func TypeOf

func TypeOf(key string, v any) slog.Attr

TypeOf returns a slog attribute with the type name of the given value.

Types

type ContextHandler

type ContextHandler struct {
	slog.Handler
}

ContextHandler wraps a slog.Handler and automatically adds trace context to log records. When a valid OpenTelemetry span is present in the context, trace_id and span_id are added.

func (*ContextHandler) Handle

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

Handle adds trace context attributes to the record before delegating to the wrapped handler.

func (*ContextHandler) WithAttrs

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

WithAttrs returns a new handler with the given attributes.

func (*ContextHandler) WithGroup

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

WithGroup returns a new handler with the given group name.

Jump to

Keyboard shortcuts

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