minimal support for RUST_LOG env variable
only supports: error,warn,info,debug,trace,off if not set or any other value maps to info
This commit is contained in:
parent
bd468e6027
commit
dfbb5a11f8
16
src/main.rs
16
src/main.rs
@ -5,7 +5,7 @@ mod model;
|
||||
|
||||
use app::CalendarApp;
|
||||
use iced::Task;
|
||||
use std::path;
|
||||
use std::{env, path};
|
||||
use clap::Parser;
|
||||
use log::info;
|
||||
use simplelog::{SimpleLogger, Config};
|
||||
@ -70,5 +70,17 @@ pub fn main() -> iced::Result {
|
||||
}
|
||||
|
||||
fn set_up_logger() {
|
||||
SimpleLogger::init(log::LevelFilter::Info, Config::default()).unwrap();
|
||||
let level = match env::var("RUST_LOG") {
|
||||
Err(_) => log::LevelFilter::Info,
|
||||
Ok(value) => match value.as_str() {
|
||||
"error" => log::LevelFilter::Error,
|
||||
"warn" => log::LevelFilter::Warn,
|
||||
"info" => log::LevelFilter::Info,
|
||||
"debug" => log::LevelFilter::Debug,
|
||||
"trace" => log::LevelFilter::Trace,
|
||||
"off" => log::LevelFilter::Off,
|
||||
_ => log::LevelFilter::Info // anything else maps to info
|
||||
}
|
||||
};
|
||||
SimpleLogger::init(level, Config::default()).unwrap();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user