adaptive_pipeline/infrastructure/
logging.rs

1// /////////////////////////////////////////////////////////////////////////////
2// Adaptive Pipeline
3// Copyright (c) 2025 Michael Gardner, A Bit of Help, Inc.
4// SPDX-License-Identifier: BSD-3-Clause
5// See LICENSE file in the project root.
6// /////////////////////////////////////////////////////////////////////////////
7
8//! # Infrastructure Logging
9//!
10//! This module provides comprehensive logging and observability capabilities
11//! for the infrastructure layer. It implements structured logging, distributed
12//! tracing, and integration with observability platforms.
13//!
14//! ## Overview
15//!
16//! The logging infrastructure provides:
17//!
18//! - **Structured Logging**: JSON-formatted logs with contextual information
19//! - **Log Levels**: Configurable severity levels (error, warn, info, debug,
20//!   trace)
21//! - **Distributed Tracing**: Trace requests across services and components
22//! - **Log Aggregation**: Integration with log aggregation systems
23//! - **Performance Monitoring**: Low-overhead logging for production
24//! - **Security**: Sensitive data filtering and redaction
25//!
26//! ## Design Principles
27//!
28//! ### Structured Logging
29//! All logs are structured for easy parsing and analysis:
30//!
31//!
32//! ### Log Levels
33//! Use appropriate log levels for different scenarios:
34//!
35//!
36//! ## Distributed Tracing
37//!
38//! Track requests across service boundaries:
39//!
40//!
41//! ## Log Formatting
42//!
43//! ### JSON Format
44//! Production logs use JSON for machine parsing:
45//!
46//! ```json
47//! {
48//!   "timestamp": "2024-01-15T10:30:00.123Z",
49//!   "level": "INFO",
50//!   "message": "Processing file",
51//!   "trace_id": "550e8400-e29b-41d4-a716-446655440000",
52//!   "span_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
53//!   "context": {
54//!     "file_path": "/data/input.txt",
55//!     "pipeline_id": "secure-backup",
56//!     "file_size_bytes": 1024000
57//!   },
58//!   "host": "server-01",
59//!   "service": "pipeline",
60//!   "version": "1.0.0"
61//! }
62//! ```
63//!
64//! ### Human-Readable Format
65//! Development logs use human-readable format:
66//!
67//! ```text
68//! 2024-01-15 10:30:00.123 INFO [trace:550e8400] Processing file
69//!   file_path: /data/input.txt
70//!   pipeline_id: secure-backup
71//!   file_size_bytes: 1024000
72//! ```
73//!
74//! ## Configuration
75//!
76//! Configure logging through the observability service:
77//!
78//!
79//! ## Log Outputs
80//!
81//! ### Console Output
82//! Log to stdout/stderr:
83//!
84//!
85//! ### File Output
86//! Log to rotating files:
87//!
88//!
89//! ### Syslog Output
90//! Log to syslog:
91//!
92//!
93//! ## Sensitive Data Filtering
94//!
95//! Automatically redact sensitive information:
96//!
97//!
98//! ## Performance Considerations
99//!
100//! ### Async Logging
101//! Logs are written asynchronously to avoid blocking:
102//!
103//!
104//! ### Sampling
105//! Sample high-volume logs:
106//!
107//!
108//! ## Integration Examples
109//!
110//! ### With Domain Events
111//!
112//!
113//! ### With Error Handling
114
115pub mod observability;
116pub use observability::*;