Setup base eframe application + serialization + arg parsing and configuration
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
use tracing::log::LevelFilter;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use tracing::debug;
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn init(is_verbose: bool) {
|
||||
let lvl_filter;
|
||||
let directive;
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
lvl_filter = LevelFilter::Info;
|
||||
directive = "yt_offline=DEBUG";
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
if is_verbose{
|
||||
lvl_filter = LevelFilter::Info;
|
||||
directive = "yt_offline=INFO";
|
||||
} else {
|
||||
lvl_filter = LevelFilter::Warn;
|
||||
directive = "yt_offline=WARN";
|
||||
}
|
||||
}
|
||||
|
||||
let filter = EnvFilter::builder()
|
||||
.with_default_directive(lvl_filter.as_str().parse().expect("Failed to parse lvl_filter into directive"))
|
||||
.from_env().expect("Failed to parse env filter")
|
||||
.add_directive(directive.parse().expect("Failed to parse directive"));
|
||||
tracing_subscriber::fmt().with_env_filter(filter).compact().init();
|
||||
debug!("Successfully setup tracing subscriber.");
|
||||
}
|
||||
Reference in New Issue
Block a user