~nickbp/originz

ref: 41895a73626b9e101ebd940b9de825c18ceb27f1 originz/src/logging.rs -rw-r--r-- 480 bytes
41895a73Nick Parker Only build binary in docker build 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use tracing;
use tracing_subscriber::EnvFilter;

pub fn init_logging() {
    let filter_layer = EnvFilter::try_from_env("LOG_LEVEL")
        .or_else(|_| EnvFilter::try_new("info"))
        .expect("Failed to initialize filter layer");

    tracing::subscriber::set_global_default(
        tracing_subscriber::fmt()
            .with_writer(std::io::stderr)
            .with_env_filter(filter_layer)
            .finish()
    )
    .expect("Failed to set default subscriber");
}