main: make log level dynamic
* set the log level via environment variable Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -29,7 +29,7 @@ use advotracker::widgets::main_view;
|
||||
|
||||
mod parse_args;
|
||||
|
||||
/// respect environment variables set in .env files
|
||||
/// define valid environment variables provided via .env files
|
||||
/// located in the current call directory
|
||||
/// this is primarily used in testing scenarios (eg. debugging)
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -71,15 +71,20 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
//static DEFAULT_FILTER: &str = concat!(module_path!(), "=", "trace");
|
||||
|
||||
// respect dotenv environment (e.g for testing)
|
||||
// -> overwrites the preset default values
|
||||
let log = dotenv::var("RUST_LOG").unwrap_or_else(|_| String::from("None"));
|
||||
|
||||
// initialize the tracing subsystem
|
||||
// a drop in replacement for classical logging
|
||||
// reference: https://tokio.rs/blog/2019-08-tracing/
|
||||
let span = tracing::span!(Level::TRACE, "csv-test");
|
||||
|
||||
let span = tracing::span!(Level::TRACE, "advotracker");
|
||||
let _enter = span.enter();
|
||||
let subscriber = fmt::Subscriber::builder()
|
||||
.with_env_filter("trace")
|
||||
//.with_max_level(tracing::Level::DEBUG)
|
||||
.finish();
|
||||
.with_env_filter(&log)
|
||||
//.with_max_level(tracing::Level::DEBUG)
|
||||
.finish();
|
||||
|
||||
tracing::subscriber::with_default(subscriber, || {
|
||||
// get system environment
|
||||
|
||||
Reference in New Issue
Block a user