helia_utils/
logger.rs

1//! Logger implementations
2
3use crate::LoggerConfig;
4use helia_interface::ComponentLogger;
5
6/// Tracing-based logger implementation
7pub struct TracingLogger {
8    _config: LoggerConfig,
9}
10
11impl TracingLogger {
12    pub fn new(config: LoggerConfig) -> Self {
13        // Initialize tracing subscriber if not already initialized
14        let _ = tracing_subscriber::fmt()
15            .with_max_level(config.level)
16            .with_ansi(true)
17            .try_init();
18
19        Self { _config: config }
20    }
21}
22
23impl ComponentLogger for TracingLogger {
24    fn debug(&self, message: &str) {
25        tracing::debug!("{}", message);
26    }
27
28    fn info(&self, message: &str) {
29        tracing::info!("{}", message);
30    }
31
32    fn warn(&self, message: &str) {
33        tracing::warn!("{}", message);
34    }
35
36    fn error(&self, message: &str) {
37        tracing::error!("{}", message);
38    }
39}