diff --git a/Cargo.toml b/Cargo.toml index 23b3b14..63f9787 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,6 +132,10 @@ tracing-subscriber = "0.3" [lints] workspace = true +[[example]] +name = "log" +required-features = ["log"] + [[example]] name = "tracing" required-features = ["tracing"] diff --git a/src/lib.rs b/src/lib.rs index c615862..83dfc19 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -215,7 +215,7 @@ impl Filter { 2 => Filter::Warn, 3 => Filter::Info, 4 => Filter::Debug, - 5.. => Filter::Trace, + _ => Filter::Trace, } } } @@ -275,10 +275,12 @@ pub trait LogLevel { #[cfg(test)] mod test { + #[allow(unused_imports)] use super::*; #[test] - fn verify_app() { + #[cfg(feature = "log")] + fn default_verbosity() { #[derive(Debug, clap::Parser)] struct Cli { #[command(flatten)] @@ -288,4 +290,30 @@ mod test { use clap::CommandFactory; Cli::command().debug_assert(); } + + #[test] + #[cfg(feature = "log")] + fn verbosity_with_log() { + #[derive(Debug, clap::Parser)] + struct Cli { + #[command(flatten)] + verbose: Verbosity, + } + + use clap::CommandFactory; + Cli::command().debug_assert(); + } + + #[test] + #[cfg(feature = "tracing")] + fn verbosity_with_tracing() { + #[derive(Debug, clap::Parser)] + struct Cli { + #[command(flatten)] + verbose: Verbosity, + } + + use clap::CommandFactory; + Cli::command().debug_assert(); + } }