pub struct CerrWrite { /* private fields */ }Expand description
A factory for creating loggers that write directly to the standard error (stderr).
CerrWrite provides a high-level builder for console logging. This is the
recommended choice for professional CLI applications, as it ensures that
diagnostic information (logs) does not interfere with the primary data
stream sent to stdout.
§Default Configuration
- Max Retries:
3(Resilience against transient I/O blocks or terminal pressure). - Worker Count:
1(Ensures logs appear in strict chronological order).
Implementations§
Source§impl CerrWrite
impl CerrWrite
Sourcepub fn get_max_retries(&self) -> usize
pub fn get_max_retries(&self) -> usize
Returns the currently configured maximum retry attempts.
Sourcepub fn get_worker_count(&self) -> usize
pub fn get_worker_count(&self) -> usize
Returns the currently configured background worker count.
Sourcepub fn max_retries(self, max_retries: usize) -> Self
pub fn max_retries(self, max_retries: usize) -> Self
Updates the maximum number of retry attempts for the stderr service.
Useful if the error stream is being redirected to a file or pipe that may experience intermittent congestion.
Sourcepub fn worker_count(self, worker_count: usize) -> Self
pub fn worker_count(self, worker_count: usize) -> Self
Updates the background worker count for asynchronous error logging.
Note: Using a worker count of 1 is strongly advised for stderr to prevent terminal interleaving and preserve message order.
Sourcepub fn build(self, concurrency: Concurrency) -> Logger
pub fn build(self, concurrency: Concurrency) -> Logger
Finalizes the logger using the StandardWriteMessageFormatter and a Concurrency strategy.
Sourcepub fn build_with_formatter<MF>(
self,
concurrency: Concurrency,
formatter: MF,
) -> Loggerwhere
MF: WriteMessageFormatter + 'static,
pub fn build_with_formatter<MF>(
self,
concurrency: Concurrency,
formatter: MF,
) -> Loggerwhere
MF: WriteMessageFormatter + 'static,
Finalizes the logger using a custom WriteMessageFormatter and a Concurrency strategy.
This is frequently used to apply “error red” ANSI styling or specialized headers specifically for diagnostic output.
Sourcepub fn build_impl_direct(self) -> Box<DirectLogger>
pub fn build_impl_direct(self) -> Box<DirectLogger>
Builds the underlying DirectLogger implementation for stderr.
Sourcepub fn build_impl_queued(self) -> Box<QueuedLogger>
pub fn build_impl_queued(self) -> Box<QueuedLogger>
Builds the underlying QueuedLogger implementation for stderr.
Sourcepub fn build_impl_direct_with_formatter<MF>(
self,
formatter: MF,
) -> Box<DirectLogger>where
MF: WriteMessageFormatter + 'static,
pub fn build_impl_direct_with_formatter<MF>(
self,
formatter: MF,
) -> Box<DirectLogger>where
MF: WriteMessageFormatter + 'static,
Builds a DirectLogger with a specific formatter for stderr.
Sourcepub fn build_impl_queued_with_formatter<MF>(
self,
formatter: MF,
) -> Box<QueuedLogger>where
MF: WriteMessageFormatter + 'static,
pub fn build_impl_queued_with_formatter<MF>(
self,
formatter: MF,
) -> Box<QueuedLogger>where
MF: WriteMessageFormatter + 'static,
Builds a QueuedLogger with a specific formatter for stderr.
Sourcepub fn build_service_with_formatter<MF>(
self,
formatter: MF,
) -> Box<CerrWrite<MF>>where
MF: WriteMessageFormatter + 'static,
pub fn build_service_with_formatter<MF>(
self,
formatter: MF,
) -> Box<CerrWrite<MF>>where
MF: WriteMessageFormatter + 'static,
Internal helper to construct the service::CerrWrite service with a custom formatter.
Sourcepub fn build_service(self) -> Box<CerrWrite<StandardWriteMessageFormatter>>
pub fn build_service(self) -> Box<CerrWrite<StandardWriteMessageFormatter>>
Internal helper to construct the service::CerrWrite service with the standard formatter.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CerrWrite
impl RefUnwindSafe for CerrWrite
impl Send for CerrWrite
impl Sync for CerrWrite
impl Unpin for CerrWrite
impl UnwindSafe for CerrWrite
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