MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / init_tracing

Function init_tracing

nodedb/src/bootstrap/tracing_init.rs:15–36  ·  view source on GitHub ↗

Initialise the global tracing subscriber based on the config log format. Uses `RUST_LOG` env var for the filter if set; otherwise defaults to `warn` for a clean startup. Must be called after config is loaded and before any `tracing::info!` / `tracing::warn!` calls are expected to emit.

(config: &ServerConfig)

Source from the content-addressed store, hash-verified

13/// for a clean startup. Must be called after config is loaded and before any
14/// `tracing::info!` / `tracing::warn!` calls are expected to emit.
15pub fn init_tracing(config: &ServerConfig) {
16 let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("warn"));
17 if config.server.log_format == crate::config::LogFormat::Json {
18 tracing_subscriber::registry()
19 .with(
20 tracing_subscriber::fmt::layer()
21 .with_writer(std::io::stderr)
22 .json()
23 .flatten_event(true)
24 .with_filter(filter),
25 )
26 .init();
27 } else {
28 tracing_subscriber::registry()
29 .with(
30 tracing_subscriber::fmt::layer()
31 .with_writer(std::io::stderr)
32 .with_filter(filter),
33 )
34 .init();
35 }
36}

Callers 1

mainFunction · 0.85

Calls 2

registryFunction · 0.85
initMethod · 0.45

Tested by

no test coverage detected