pub struct Direct { /* private fields */ }Expand description
A synchronous logging implementation that performs immediate writes.
SyncLogger blocks the current thread until the Service successfully
processes the Message or the max_retries threshold is reached.
Because it implements LoggerImpl, it can be wrapped in the primary
Logger struct and shared across threads.
Implementations§
Source§impl Direct
impl Direct
Sourcepub fn new(
service: Box<dyn Service + Send + Sync>,
max_retries: usize,
) -> Box<Self>
pub fn new( service: Box<dyn Service + Send + Sync>, max_retries: usize, ) -> Box<Self>
Creates a new DirectLogger with a specified backend service and retry policy.
§Arguments
service- The backend execution logic (e.g., File, Console).max_retries- How many additional times to try if the first attempt fails.
Sourcepub fn get_service(&self) -> &dyn Service
pub fn get_service(&self) -> &dyn Service
Returns the base service
Trait Implementations§
Source§impl LoggerImpl for Direct
impl LoggerImpl for Direct
Source§fn status(&self) -> LoggerStatus
fn status(&self) -> LoggerStatus
Delegates the health check to the underlying Service.
Source§fn log(&self, message: Message)
fn log(&self, message: Message)
Attempts to log the message synchronously.
If the first attempt fails, it will retry up to max_retries times.
Since the high-level API is fire-and-forget, failures after all
retries are exhausted are currently dropped silently to maintain
the LoggerImpl contract.
If all retries fail the fallback is used.
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Enables runtime downcasting to DirectLogger.
Auto Trait Implementations§
impl Freeze for Direct
impl !RefUnwindSafe for Direct
impl Send for Direct
impl Sync for Direct
impl Unpin for Direct
impl !UnwindSafe for Direct
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