about summary refs log tree commit diff stats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/cli.rs2
-rw-r--r--src/main.rs31
2 files changed, 28 insertions, 5 deletions
diff --git a/src/cli.rs b/src/cli.rs
index d3ec262..1638e05 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -30,7 +30,7 @@ pub struct CliArgs {
     pub command: Option<Command>,
 
     /// Increase message verbosity
-    #[arg(long="verbose", short = 'v', action = ArgAction::Count)]
+    #[arg(long="verbose", short = 'v', action = ArgAction::Count, default_value_t = u8::MAX)]
     pub verbosity: u8,
 
     /// Set the path to the videos.db. This overrides the default and the config file.
diff --git a/src/main.rs b/src/main.rs
index a30dc24..5e22dc7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,7 +8,7 @@
 // You should have received a copy of the License along with this program.
 // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 
-use std::{collections::HashMap, fs, sync::Arc};
+use std::{collections::HashMap, fs, sync::Arc, u8};
 
 use anyhow::{bail, Context, Result};
 use app::App;
@@ -45,19 +45,42 @@ pub mod watch;
 #[tokio::main]
 async fn main() -> Result<()> {
     let args = cli::CliArgs::parse();
+
+    let verbosity: u8 = if args.verbosity == u8::MAX {
+        // the user did not specify a verbosity
+        2 // log::Level::Warn
+    } else {
+        assert!(args.verbosity > 0);
+
+        args.verbosity + 2 // log::Level::Warn
+    };
+
     stderrlog::new()
         .module(module_path!())
         .modules(&["yt_dlp".to_owned(), "libmpv2".to_owned()])
         .quiet(args.quiet)
         .show_module_names(false)
         .color(stderrlog::ColorChoice::Auto)
-        .verbosity(args.verbosity as usize)
+        .verbosity(verbosity as usize)
         .timestamp(stderrlog::Timestamp::Off)
         .init()
         .expect("Let's just hope that this does not panic");
 
-    let config = Config::from_config_file(args.db_path, args.config_path)?;
-    let app = App::new(config).await?;
+    info!("Using verbosity level: '{} ({})'", verbosity, {
+        match verbosity {
+            0 => "Off",
+            1 => "Error",
+            2 => "Warn",
+            3 => "Info",
+            4 => "Debug",
+            5.. => "Trace",
+        }
+    });
+
+    let app = {
+        let config = Config::from_config_file(args.db_path, args.config_path)?;
+        App::new(config).await?
+    };
 
     match args.command.unwrap_or(Command::default()) {
         Command::Download {