Browse Source

util/cli: Allow ignores for LOG_TARGETS in log_config.

parazyd 4 years ago
parent
commit
4d96539c9f
2 changed files with 8 additions and 3 deletions
  1. 1 1
      src/util/async_util.rs
  2. 7 2
      src/util/cli.rs

+ 1 - 1
src/util/async_util.rs

@@ -3,5 +3,5 @@ use std::time::Duration;
 
 
 /// Sleep for any number of seconds.
 /// Sleep for any number of seconds.
 pub async fn sleep(seconds: u64) {
 pub async fn sleep(seconds: u64) {
-    Timer::after(Duration::from_secs(seconds.into())).await;
+    Timer::after(Duration::from_secs(seconds)).await;
 }
 }

+ 7 - 2
src/util/cli.rs

@@ -61,10 +61,15 @@ pub fn log_config(verbosity_level: u64) -> Result<(simplelog::LevelFilter, simpl
 
 
     let log_config = match env::var("LOG_TARGETS") {
     let log_config = match env::var("LOG_TARGETS") {
         Ok(x) => {
         Ok(x) => {
-            let targets: Vec<&str> = x.split(',').collect();
+            let targets: Vec<String> = x.split(',').map(|x| x.to_string()).collect();
             let mut cfgbuilder = ConfigBuilder::new();
             let mut cfgbuilder = ConfigBuilder::new();
+
             for i in targets {
             for i in targets {
-                cfgbuilder.add_filter_allow(i.to_string());
+                if i.starts_with('!') {
+                    cfgbuilder.add_filter_ignore(i.trim_start_matches('!').to_string());
+                } else {
+                    cfgbuilder.add_filter_allow(i);
+                }
             }
             }
 
 
             cfgbuilder.build()
             cfgbuilder.build()