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;
|
mod parse_args;
|
||||||
|
|
||||||
/// respect environment variables set in .env files
|
/// define valid environment variables provided via .env files
|
||||||
/// located in the current call directory
|
/// located in the current call directory
|
||||||
/// this is primarily used in testing scenarios (eg. debugging)
|
/// this is primarily used in testing scenarios (eg. debugging)
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
@@ -71,13 +71,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
//static DEFAULT_FILTER: &str = concat!(module_path!(), "=", "trace");
|
//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
|
// initialize the tracing subsystem
|
||||||
// a drop in replacement for classical logging
|
// a drop in replacement for classical logging
|
||||||
// reference: https://tokio.rs/blog/2019-08-tracing/
|
// 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 _enter = span.enter();
|
||||||
let subscriber = fmt::Subscriber::builder()
|
let subscriber = fmt::Subscriber::builder()
|
||||||
.with_env_filter("trace")
|
.with_env_filter(&log)
|
||||||
//.with_max_level(tracing::Level::DEBUG)
|
//.with_max_level(tracing::Level::DEBUG)
|
||||||
.finish();
|
.finish();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user