diff --git a/src/main.rs b/src/main.rs index a855bc8..16f4e9c 100644 --- a/src/main.rs +++ b/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(); }