diff --git a/src/main.rs b/src/main.rs index 45eeb3a..df51139 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,21 +39,26 @@ struct Args { origin: Option, #[arg(short, long)] agent: Option, + #[arg(short, action = clap::ArgAction::Count, help = "Increase verbosity")] + verbose: u8, } #[tokio::main] async fn main() -> anyhow::Result<()> { + let args = Args::parse(); + + let log_level = match args.verbose { + 0 => "error", + 1 => "info", + _ => "debug", + }; + let env = Env::default() - . filter_or("LOG_LEVEL", "error") + . filter_or("LOG_LEVEL", log_level) . write_style_or("LOG_STYLE", "always"); env_logger::init_from_env(env); - info!("Parse command line arguments..."); - - let args = Args::parse(); - debug!("Arguments: {:?}", args); - let name = args.name.as_path(); if name.file_name() != Some(OsStr::new(name)) {