diff options
| author | Fuwn <[email protected]> | 2021-05-15 16:32:39 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-15 16:32:39 +0000 |
| commit | 4389bd9d3661a6a0e45d50c54f6489bb8f24851b (patch) | |
| tree | 4ae88aacc461fac21226392a871a9bd56e9c1b03 /src/cli.rs | |
| parent | feat(global): logs now go to a dedicated directory and file (diff) | |
| download | whirl-4389bd9d3661a6a0e45d50c54f6489bb8f24851b.tar.xz whirl-4389bd9d3661a6a0e45d50c54f6489bb8f24851b.zip | |
feat(config): better logging configuration
Logging is very much imporved in just about every aspect.
BREAKING CHANGE: `whirlsplash.log` configuration group created, `whirlsplash.log_level`
configuration key removed.
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -10,13 +10,20 @@ impl Cli { pub fn setup() -> ArgMatches<'static> { let matches = Self::cli().get_matches(); - Self::calc_log_level(&matches); std::env::set_var("DATABASE_URL", "whirl.sqlite3"); matches } pub async fn execute(matches: ArgMatches<'_>) { + if Config::get().whirlsplash.log.test { + error!("error"); + warn!("warn"); + info!("info"); + debug!("debug"); + trace!("trace"); + } + if matches.is_present("run") { run().await; } else if let Some(cmd) = matches.subcommand_matches("config") { @@ -39,17 +46,6 @@ impl Cli { } } - fn calc_log_level(matches: &ArgMatches<'_>) { - let mut log_level = "whirl=error,whirl=warn,whirl=trace".to_string(); - if matches.is_present("debug") || Config::get().whirlsplash.log_level >= 2 { - log_level += ",whirl=debug"; - } - if matches.is_present("trace") || Config::get().whirlsplash.log_level >= 3 { - log_level += ",whirl=trace"; - } - std::env::set_var("RUST_LOG", log_level); - } - fn cli<'a, 'b>() -> App<'a, 'b> { App::new(env!("CARGO_PKG_NAME")) .about(env!("CARGO_PKG_DESCRIPTION")) |