logging

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentID

func AgentID(ctx context.Context) string

AgentID extracts the agent ID from the context, or "" if absent.

func LogWith

func LogWith(ctx context.Context, logger *slog.Logger) *slog.Logger

LogWith returns a logger enriched with correlation IDs from the context. Only non-empty values are added as attributes.

func StepID

func StepID(ctx context.Context) string

StepID extracts the step ID from the context, or "" if absent.

func WithAgentID

func WithAgentID(ctx context.Context, id string) context.Context

WithAgentID returns a context with the agent ID set.

func WithIDs

func WithIDs(ctx context.Context, workflowID, stepID, agentID string) context.Context

WithIDs sets all three correlation IDs on the context at once.

func WithStepID

func WithStepID(ctx context.Context, id string) context.Context

WithStepID returns a context with the step ID set.

func WithWorkflowID

func WithWorkflowID(ctx context.Context, id string) context.Context

WithWorkflowID returns a context with the workflow ID set.

func WorkflowID

func WorkflowID(ctx context.Context) string

WorkflowID extracts the workflow ID from the context, or "" if absent.

Types

type CorrelationHandler

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

CorrelationHandler wraps an slog.Handler, automatically injecting correlation IDs from the context into every log record. Use with slog.New(NewCorrelationHandler(inner)) so callers can use logger.InfoContext(ctx, ...) and IDs appear automatically.

func NewCorrelationHandler

func NewCorrelationHandler(inner slog.Handler) *CorrelationHandler

NewCorrelationHandler wraps the given handler with automatic correlation ID injection.

func (*CorrelationHandler) Enabled

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

func (*CorrelationHandler) Handle

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

func (*CorrelationHandler) WithAttrs

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

func (*CorrelationHandler) WithGroup

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

Jump to

Keyboard shortcuts

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