pub fn init_logging(
config: LoggingConfig,
) -> Result<(), Box<dyn Error + Send + Sync>>Expand description
Initialize logging with the given configuration
This function sets up the tracing subscriber with the appropriate layers based on configuration:
- Console output (plain text or JSON)
- Optional file output with rotation
- Optional OpenTelemetry tracing layer
§Arguments
config- Logging configuration
§Example
use mockforge_observability::logging::{LoggingConfig, init_logging};
let config = LoggingConfig {
level: "info".to_string(),
json_format: true,
file_path: Some("logs/mockforge.log".into()),
max_file_size_mb: 10,
max_files: 5,
};
init_logging(config).expect("Failed to initialize logging");