1pub mod cmd;
2pub mod data;
3pub mod fs;
4pub mod git;
5pub mod os;
6
7pub fn tracing_init(level: Option<tracing::Level>) -> anyhow::Result<()> {
8 use tracing_subscriber::{fmt, layer::SubscriberExt, EnvFilter, Layer};
9
10 if let Some(level) = level {
11 let layer_stderr = fmt::Layer::new()
12 .with_writer(std::io::stderr)
13 .with_ansi(true)
14 .with_file(false)
15 .with_line_number(true)
16 .with_thread_ids(true)
17 .with_filter(
19 EnvFilter::from_default_env().add_directive(level.into()),
20 );
21 tracing::subscriber::set_global_default(
22 tracing_subscriber::registry().with(layer_stderr),
23 )?;
24 }
25 Ok(())
26}