Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Clarify role of each API item #78

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading