Skip to content

Commit

Permalink
Merge pull request #506 from KodrAus/chore/enabled-requirement
Browse files Browse the repository at this point in the history
Note that Log implementors should call enabled
  • Loading branch information
KodrAus authored Apr 28, 2022
2 parents 6c3cd4a + c9049be commit b7e8147
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1273,10 +1273,18 @@ pub trait Log: Sync + Send {
/// This is used by the `log_enabled!` macro to allow callers to avoid
/// expensive computation of log message arguments if the message would be
/// discarded anyway.
///
/// # For implementors
///
/// This method isn't called automatically by the `log!` macros.
/// It's up to an implementation of the `Log` trait to call `enabled` in its own
/// `log` method implementation to guarantee that filtering is applied.
fn enabled(&self, metadata: &Metadata) -> bool;

/// Logs the `Record`.
///
/// # For implementors
///
/// Note that `enabled` is *not* necessarily called before this method.
/// Implementations of `log` should perform all necessary filtering
/// internally.
Expand Down

0 comments on commit b7e8147

Please sign in to comment.