shared_logging/
lib.rs

1//! Shared logging library with structured logging, context propagation, redaction, and HTTP middleware.
2//!
3//! # Features
4//!
5//! - Structured logger wrapper with consistent field names
6//! - Context propagation: trace_id, span_id, request_id, user_id, tenant_id
7//! - Redaction helpers for PII, secrets, and tokens
8//! - Standard event schema with consistent field names and error formatting
9//! - HTTP middleware for request ID injection and request lifecycle logging
10//! - Optional OpenTelemetry log correlation
11//!
12//! # Example
13//!
14//! ```no_run
15//! use shared_logging::{init_logger, Logger};
16//!
17//! // Initialize the logger
18//! init_logger("my-service", "info").unwrap();
19//!
20//! // Create a logger instance
21//! let logger = Logger::new("my-module");
22//!
23//! // Log with context
24//! logger.info("User logged in", |e| {
25//!     e.field("user_id", "user123");
26//! });
27//! ```
28
29pub mod context;
30pub mod logger;
31pub mod redaction;
32pub mod schema;
33
34#[cfg(feature = "http")]
35pub mod middleware;
36
37#[cfg(feature = "otel")]
38pub mod otel;
39
40pub use context::{Context, ContextBuilder};
41pub use logger::{init_logger, Logger};
42pub use redaction::{Redaction, Redactor};
43pub use schema::{Event, Level, StandardFields};
44