๐Ÿ“ฆ jieyouxu / rustc-less-ignore-debug

๐Ÿ“„ logging.rs ยท 25 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25use tracing::*;

pub(crate) fn setup_logging() {
    use tracing::metadata::LevelFilter;
    use tracing_subscriber::prelude::*;
    use tracing_subscriber::{fmt, EnvFilter};

    let stderr_log = fmt::layer()
        .with_writer(std::io::stderr)
        .compact()
        .with_level(true)
        .with_target(true)
        .without_time()
        .with_filter(
            EnvFilter::builder()
                .with_default_directive(LevelFilter::INFO.into())
                .from_env_lossy(),
        );
    let subscriber = tracing_subscriber::registry().with(stderr_log);

    tracing::subscriber::set_global_default(subscriber).unwrap();

    debug!("tracing subscriber set up");
}