From c9284a68426fbe4c009507a03a313f5a20c40085 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Wed, 20 Apr 2022 20:53:51 +1000 Subject: [PATCH 1/2] note that Log implementors should call enabled --- src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index ff18c6029..1c0703351 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1273,6 +1273,12 @@ 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`. From c9049be6165f8231eb1145023748be372640640e Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Fri, 29 Apr 2022 08:42:34 +1000 Subject: [PATCH 2/2] make notes for implementors consistent --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 1c0703351..4e979c497 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1283,6 +1283,8 @@ pub trait Log: Sync + Send { /// Logs the `Record`. /// + /// # For implementors + /// /// Note that `enabled` is *not* necessarily called before this method. /// Implementations of `log` should perform all necessary filtering /// internally.