pub struct Cout<F>where
F: MessageFormatter,{ /* private fields */ }Expand description
A logging Service that targets the standard output stream (std::io::stdout).
Unlike other Services, Cout service does not own its writer. Instead, it
acquires a handle to the global process stdout during every work call.
§Why the Mutex?
Even though stdout is globally available, the MessageFormatter (field formatter)
may hold internal state (like line counters or timing data) that is not thread-safe.
Wrapping the formatter in a Mutex ensures that the formatting logic remains
atomic and synchronized across threads.
Implementations§
Trait Implementations§
Source§impl<F> Fallback for Cout<F>where
F: MessageFormatter + 'static,
impl<F> Fallback for Cout<F>where
F: MessageFormatter + 'static,
Source§fn fallback(&self, error: &ServiceError, msg: &Message)
fn fallback(&self, error: &ServiceError, msg: &Message)
Emergency fallback that attempts to log the error back to stdout.
If the formatter is locked or poisoned, the fallback is aborted to avoid deadlocks.
Source§impl<F> Service for Cout<F>where
F: MessageFormatter + 'static,
impl<F> Service for Cout<F>where
F: MessageFormatter + 'static,
Source§fn work(&self, msg: &Message) -> Result<(), ServiceError>
fn work(&self, msg: &Message) -> Result<(), ServiceError>
Acquires the formatter lock and streams the formatted message to stdout.
This method locks the global stdout stream for the duration of the formatting
process. This prevents “line interleaving” where parts of different log
messages appear mixed in the console.
§Errors
Returns ServiceError::LockPoisoned if the internal formatter mutex is poisoned.
Source§fn status(&self) -> LoggerStatus
fn status(&self) -> LoggerStatus
[LoggerStatus] of the service.Auto Trait Implementations§
impl<F> !Freeze for Cout<F>
impl<F> RefUnwindSafe for Cout<F>
impl<F> Send for Cout<F>
impl<F> Sync for Cout<F>
impl<F> Unpin for Cout<F>where
F: Unpin,
impl<F> UnwindSafe for Cout<F>
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