template_rust_project/
logging.rs

1use ctor::ctor;
2use tracing::Level;
3use tracing_subscriber;
4
5#[ctor]
6fn set_debug_level() {
7    // If DEBUG_PROJ is not set or set to false, disable logging. Otherwise, enable logging
8    if std::env::var("DEBUG_PROJ").map_or(true, |v| v == "0" || v == "false" || v.is_empty()) {
9        // Disable logging
10    } else {
11        tracing_subscriber::fmt()
12            .with_max_level(Level::DEBUG)
13            .init();
14    }
15
16    //println!("DEBUG_PROJ: {:?}", std::env::var("DEBUG_PROJ"));
17}