diff --git a/src/cli.rs b/src/cli.rs index 4908650..f6538da 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -82,9 +82,9 @@ pub struct Args { #[arg(long, value_delimiter = ',')] toolchains: Vec, - /// Turn verbose information on - #[arg(short, long)] - pub verbose: bool, + /// Enable DEBUG logs (use twice for TRACE logs) + #[arg(short, long, action = clap::ArgAction::Count)] + pub verbose: u8, } impl Args { diff --git a/src/fingerprint.rs b/src/fingerprint.rs index 026ac27..0cdcf4f 100644 --- a/src/fingerprint.rs +++ b/src/fingerprint.rs @@ -1,5 +1,6 @@ #![allow(deprecated)] use anyhow::{bail, Context, Error}; +use log::trace; use log::{debug, info, warn}; use serde_derive::Deserialize; use serde_json::from_str; @@ -94,7 +95,7 @@ fn load_all_fingerprints_built_with( } } } - debug!("Hashs to keep: {:#?}", keep); + trace!("Hashs to keep: {:#?}", keep); Ok(keep) } @@ -156,7 +157,7 @@ fn load_all_fingerprints_newer_than( } } } - debug!("Hashs to keep: {:#?}", keep); + trace!("Hashs to keep: {:#?}", keep); Ok(keep) } diff --git a/src/main.rs b/src/main.rs index 0d3f45b..20c1d8f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,11 +25,11 @@ use self::stamp::Timestamp; use self::util::format_bytes; /// Setup logging according to verbose flag. -fn setup_logging(verbose: bool) { - let level = if verbose { - log::LevelFilter::Debug - } else { - log::LevelFilter::Info +fn setup_logging(verbosity_level: u8) { + let level = match verbosity_level { + 0 => log::LevelFilter::Info, + 1 => log::LevelFilter::Debug, + 2.. => log::LevelFilter::Trace, }; let isatty = std::io::stdout().is_tty(); diff --git a/tests/usage.trycmd b/tests/usage.trycmd index 00fdbb6..e2a0bf8 100644 --- a/tests/usage.trycmd +++ b/tests/usage.trycmd @@ -17,7 +17,7 @@ Options: -s, --stamp Store timestamp file at the given path, is used by file option -t, --time Number of days backwards to keep --toolchains Toolchains currently installed by rustup that should have their artifacts kept - -v, --verbose Turn verbose information on + -v, --verbose... Enable DEBUG logs (use twice for TRACE logs) -h, --help Print help (see more with '--help') -V, --version Print version