diff --git a/crunchy-cli-core/src/cli/log.rs b/crunchy-cli-core/src/cli/log.rs index d4bb1b3..3539733 100644 --- a/crunchy-cli-core/src/cli/log.rs +++ b/crunchy-cli-core/src/cli/log.rs @@ -92,6 +92,7 @@ impl CliProgress { #[allow(clippy::type_complexity)] pub struct CliLogger { + all: bool, level: LevelFilter, progress: Mutex>, } @@ -105,7 +106,7 @@ impl Log for CliLogger { if !self.enabled(record.metadata()) || (record.target() != "progress" && record.target() != "progress_end" - && !record.target().starts_with("crunchy_cli")) + && (!self.all && !record.target().starts_with("crunchy_cli"))) { return; } @@ -136,16 +137,17 @@ impl Log for CliLogger { } impl CliLogger { - pub fn new(level: LevelFilter) -> Self { + pub fn new(all: bool, level: LevelFilter) -> Self { Self { + all, level, progress: Mutex::new(None), } } - pub fn init(level: LevelFilter) -> Result<(), SetLoggerError> { + pub fn init(all: bool, level: LevelFilter) -> Result<(), SetLoggerError> { set_max_level(level); - set_boxed_logger(Box::new(CliLogger::new(level))) + set_boxed_logger(Box::new(CliLogger::new(all, level))) } fn extended(&self, record: &Record) { diff --git a/crunchy-cli-core/src/lib.rs b/crunchy-cli-core/src/lib.rs index a1e8381..9b57859 100644 --- a/crunchy-cli-core/src/lib.rs +++ b/crunchy-cli-core/src/lib.rs @@ -64,6 +64,10 @@ struct Verbosity { #[arg(short)] v: bool, + #[arg(help = "Very verbose output. Generally not recommended, use '-v' instead")] + #[arg(long)] + vv: bool, + #[arg(help = "Quiet output. Does not print anything unless it's a error")] #[arg( long_help = "Quiet output. Does not print anything unless it's a error. Can be helpful if you pipe the output to stdout" @@ -92,16 +96,18 @@ pub async fn cli_entrypoint() { let cli: Cli = Cli::parse(); if let Some(verbosity) = &cli.verbosity { - if verbosity.v && verbosity.q { + if verbosity.v as u8 + verbosity.q as u8 + verbosity.vv as u8 > 1 { eprintln!("Output cannot be verbose ('-v') and quiet ('-q') at the same time"); std::process::exit(1) } else if verbosity.v { - CliLogger::init(LevelFilter::Debug).unwrap() + CliLogger::init(false, LevelFilter::Debug).unwrap() } else if verbosity.q { - CliLogger::init(LevelFilter::Error).unwrap() + CliLogger::init(false, LevelFilter::Error).unwrap() + } else if verbosity.vv { + CliLogger::init(true, LevelFilter::Debug).unwrap() } } else { - CliLogger::init(LevelFilter::Info).unwrap() + CliLogger::init(false, LevelFilter::Info).unwrap() } debug!("cli input: {:?}", cli);