Framework.Overlay.StructuredLogger (Framework v0.5.0)
View SourceStructured Logger for consistent correlation ID logging.
Provides standardized logging functions that automatically include {sequence, request_id, client_id, session_id} correlation metadata.
Ensures all framework logs carry required observability markers for debugging and operational monitoring.
Features
- Automatic correlation ID injection
- Sequence number tracking
- Event type classification
- PII-safe error redaction
- Performance measurement integration
Summary
Functions
Extract correlation context from outbox event.
Extract correlation context from Oban job.
Log with full correlation context.
Log effect execution with idempotency context.
Log operation end with duration calculation.
Log operation start with timing context.
Log error with safe redaction.
Log sequence event with ordering context.
Functions
Extract correlation context from outbox event.
Convenience function to build correlation context from an outbox event for consistent logging.
Extract correlation context from Oban job.
Convenience function to build correlation context from an Oban job for effect execution logging.
Log with full correlation context.
Automatically includes sequence, request_id, client_id, session_id when available from the provided context.
Parameters
level: :debug | :info | :warning | :error
- message: Log message string
- metadata: Additional metadata map
- correlation_context: Context containing correlation IDs and sequence
Examples
iex> context = %{
...> sequence: 1234,
...> request_id: "req-123",
...> client_id: "client-456",
...> session_id: "session-789"
...> }
iex> Framework.Overlay.StructuredLogger.log(:info, "Operation completed", %{}, context)
:ok
Log effect execution with idempotency context.
Specialized logging for effect execution including idempotency keys and external service interaction details.
Log operation end with duration calculation.
Calculates and logs operation duration when paired with log_operation_start/3.
Log operation start with timing context.
Creates a timing context for operation duration measurement. Use with log_operation_end/3 for complete timing.
Log error with safe redaction.
Automatically redacts potentially sensitive information from error messages while preserving debugging utility.
Log sequence event with ordering context.
Specialized logging for sequencer/emitter events that includes sequence ordering and gap information.