Compare commits

..

No commits in common. "673eb691e99629543f3b196908a5785b095d6e68" and "87dc2871d7de982d92a10ff1ddd182754df21e61" have entirely different histories.

2 changed files with 16 additions and 6 deletions

View file

@ -23,7 +23,17 @@ struct Cli {
fn main() {
let cli = Cli::parse();
let _logger = Logger::builder().set_level(cli.verbosity.level()).build();
let _logger = {
let mut this = {
let mut this = Logger::builder();
let max_level = cli.verbosity.level();
this.max_level = max_level;
this
};
this.show_time = false;
this
}
.build();
debug!("logger initialized with level: {}", cli.verbosity.level());

View file

@ -101,12 +101,12 @@ pub struct VerbosityLevel {
#[arg(
long,
short = 'v',
action = clap::ArgAction::Count, // NOTE: this forces u8 type for some reason
action = clap::ArgAction::Count,
global = true,
// help = L::verbose_help(),
// long_help = L::verbose_long_help(),
)]
verbose: u8,
verbose: i8,
/// make the output less verbose
///
@ -118,7 +118,7 @@ pub struct VerbosityLevel {
global = true,
conflicts_with = "verbose",
)]
quiet: u8,
quiet: i8,
}
impl VerbosityLevel {
@ -131,7 +131,7 @@ impl VerbosityLevel {
}
#[inline]
#[must_use]
fn value(&self) -> u8 {
fn value(&self) -> i8 {
Self::level_value(Level::INFO)
.saturating_sub((self.quiet).min(10))
.saturating_add((self.verbose).min(10))
@ -189,7 +189,7 @@ impl VerbosityLevel {
#[inline]
#[must_use]
const fn level_value(level: Level) -> u8 {
const fn level_value(level: Level) -> i8 {
match level {
Level::TRACE => 4,
Level::DEBUG => 3,