pub struct Silent;Expand description
A no-op (no-operation) implementation of LoggerImpl.
SilentLogger satisfies the logger interface while effectively discarding all
log messages. This is useful for:
- Testing: Disabling log output during unit tests.
- Defaults: Providing a safe, “do-nothing” fallback logger.
- Performance: Avoiding conditional “if logger.is_some()” checks in hot paths.
Implementations§
Source§impl Silent
impl Silent
Sourcepub fn new() -> Box<Self>
pub fn new() -> Box<Self>
Creates a new, heap-allocated instance of SilentLogger.
This is a convenience constructor that returns the logger inside a Box,
making it directly compatible with Logger::new().
§Example
let logger = Logger::new(SilentLogger::new());Trait Implementations§
Source§impl LoggerImpl for Silent
impl LoggerImpl for Silent
Source§fn status(&self) -> LoggerStatus
fn status(&self) -> LoggerStatus
Always returns LoggerStatus::Running.
Since the SilentLogger cannot fail in its mission to do nothing, it
is perpetually in a healthy state.
Source§fn log(&self, _message: Message)
fn log(&self, _message: Message)
Discards the incoming Message immediately.
This method is essentially a “black hole.” The underscore in _message
ensures the compiler does not warn about the unused variable while
the message is dropped at the end of the scope.
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Returns the SilentLogger instance as a [dyn Any].
Auto Trait Implementations§
impl Freeze for Silent
impl RefUnwindSafe for Silent
impl Send for Silent
impl Sync for Silent
impl Unpin for Silent
impl UnsafeUnpin for Silent
impl UnwindSafe for Silent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more