14 lines
642 B
Rust
14 lines
642 B
Rust
|
|
/// Only initializes a subscriber (and thus produces any log output at all)
|
||
|
|
/// when the caller opted in via `--log-level` — otherwise tracing's macros
|
||
|
|
/// are no-ops, leaving the terminal clean for the spinner.
|
||
|
|
pub(crate) fn initialize_observability(log_level: tracing::Level) {
|
||
|
|
tracing_subscriber::fmt()
|
||
|
|
.with_env_filter(
|
||
|
|
tracing_subscriber::EnvFilter::try_from_default_env()
|
||
|
|
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(log_level.to_string())),
|
||
|
|
)
|
||
|
|
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::CLOSE)
|
||
|
|
.with_writer(std::io::stderr)
|
||
|
|
.init();
|
||
|
|
}
|