Skip to content

Commit

Permalink
Use two --verbose flags as a [TRACE] log level
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospb19 committed Sep 18, 2023
1 parent fd4dc9e commit 1eaf269
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ pub struct Args {
#[arg(long, value_delimiter = ',')]
toolchains: Vec<String>,

/// 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 {
Expand Down
5 changes: 3 additions & 2 deletions src/fingerprint.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -94,7 +95,7 @@ fn load_all_fingerprints_built_with(
}
}
}
debug!("Hashs to keep: {:#?}", keep);
trace!("Hashs to keep: {:#?}", keep);
Ok(keep)
}

Expand Down Expand Up @@ -156,7 +157,7 @@ fn load_all_fingerprints_newer_than(
}
}
}
debug!("Hashs to keep: {:#?}", keep);
trace!("Hashs to keep: {:#?}", keep);
Ok(keep)
}

Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1eaf269

Please sign in to comment.