Skip to main content

init_tracing

Function init_tracing 

Source
pub fn init_tracing(log_registry: Arc<ComponentLogRegistry>)
Expand description

Tracing initialization function - call to set up component log routing Initialize the tracing subscriber with component log routing.

This sets up:

  • ComponentLogLayer for routing logs to component-specific streams
  • fmt::layer() for console output
  • EnvFilter for level control via RUST_LOG environment variable
  • tracing-log bridge for log crate compatibility

§Arguments

  • log_registry - The registry to route component logs to

§Example

use drasi_lib::managers::ComponentLogRegistry;
use std::sync::Arc;

let log_registry = Arc::new(ComponentLogRegistry::new());
drasi_lib::init_tracing(log_registry.clone());

// Now both tracing::info!() and log::info!() work
tracing::info!("Hello from tracing");
log::info!("Hello from log crate");

§Note

If another log crate logger was initialized before calling this function, log::info!() calls will go to that logger instead. However, tracing::info!() calls will still be captured correctly.

§Deprecated

Prefer using get_or_init_global_registry() which handles initialization automatically. This function is kept for backward compatibility.