use std::sync::Once;
use tracing_subscriber::fmt::format;
pub async fn logging(debug: bool) {
static START: Once = Once::new();
START.call_once(|| {
let subscriber = tracing_subscriber::fmt() .event_format(format().compact());
match debug {
true => {
subscriber
.with_line_number(true)
.with_target(true)
.with_file(true)
.with_max_level(tracing::Level::DEBUG)
.init();
}
false => {
subscriber
.with_target(false)
.with_max_level(tracing::Level::INFO)
.init();
}
}
});
}
#[cfg(test)]
#[path = "./tests/logger_test.rs"]
mod logger_test;