aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-23 14:30:48 +0000
committerFuwn <[email protected]>2021-05-23 14:30:48 +0000
commitf09ef6428a79b677288a3a1006780dbcfb7da786 (patch)
tree6a9b959e9b69da751deecf28cf24f56aeb5fa7dd
parentrefactor(prompt): move builtins constants to builtins module (diff)
downloadwhirl-f09ef6428a79b677288a3a1006780dbcfb7da786.tar.xz
whirl-f09ef6428a79b677288a3a1006780dbcfb7da786.zip
feat(whirl): conditional logging, use whirlsplash.log.enable key
-rw-r--r--crates/whirl/src/whirl.rs29
1 files changed, 16 insertions, 13 deletions
diff --git a/crates/whirl/src/whirl.rs b/crates/whirl/src/whirl.rs
index 451d79f..8b893f5 100644
--- a/crates/whirl/src/whirl.rs
+++ b/crates/whirl/src/whirl.rs
@@ -4,6 +4,7 @@
use std::error::Error;
use whirl_common::log::calculate_log_level;
+use whirl_config::Config;
use crate::cli::Cli;
@@ -16,19 +17,21 @@ impl Whirl {
// Logging
dotenv::dotenv().ok();
human_panic::setup_panic!();
- let logger = flexi_logger::Logger::with_str(calculate_log_level());
- if std::env::var("LOG_FILE").unwrap_or_else(|_| "true".to_string()) == "false"
- || !whirl_config::Config::get().whirlsplash.log.file
- || std::env::args().collect::<Vec<_>>()[1] == "clean"
- // Cheeky as all hell.
- {
- logger.start()?;
- } else {
- logger
- .print_message()
- .log_to_file()
- .directory("log")
- .start()?;
+ if Config::get().whirlsplash.log.enable {
+ let logger = flexi_logger::Logger::with_str(calculate_log_level());
+ if std::env::var("LOG_FILE").unwrap_or_else(|_| "true".to_string()) == "false"
+ || !whirl_config::Config::get().whirlsplash.log.file
+ || std::env::args().collect::<Vec<_>>()[1] == "clean"
+ // Cheeky as all hell.
+ {
+ logger.start()?;
+ } else {
+ logger
+ .print_message()
+ .log_to_file()
+ .directory("log")
+ .start()?;
+ }
}
Cli::execute(matches).await.unwrap();