Skip to content

Commit

Permalink
Merge pull request #78 from epage/docs
Browse files Browse the repository at this point in the history
docs: Clarify role of each API item
  • Loading branch information
epage authored Dec 15, 2023
2 parents c5c21e5 + a06396f commit 012f616
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@
//! }
//! ```
//!
//! Or implement [`LogLevel`] yourself for more control.
//! Or implement out [`LogLevel`] trait to customize the default log level and help output.
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

pub use log::Level;
pub use log::LevelFilter;

/// Logging flags to `#[command(flatte)]` into your CLI
#[derive(clap::Args, Debug, Clone, Default)]
pub struct Verbosity<L: LogLevel = ErrorLevel> {
#[arg(
Expand Down Expand Up @@ -151,6 +152,7 @@ impl<L: LogLevel> fmt::Display for Verbosity<L> {
}
}

/// Customize the default log-level and associated help
pub trait LogLevel {
fn default() -> Option<log::Level>;

Expand All @@ -171,6 +173,7 @@ pub trait LogLevel {
}
}

/// Default to [`log::Level::Error`]
#[derive(Copy, Clone, Debug, Default)]
pub struct ErrorLevel;

Expand All @@ -180,6 +183,7 @@ impl LogLevel for ErrorLevel {
}
}

/// Default to [`log::Level::Warn`]
#[derive(Copy, Clone, Debug, Default)]
pub struct WarnLevel;

Expand All @@ -189,6 +193,7 @@ impl LogLevel for WarnLevel {
}
}

/// Default to [`log::Level::Info`]
#[derive(Copy, Clone, Debug, Default)]
pub struct InfoLevel;

Expand Down

0 comments on commit 012f616

Please sign in to comment.