pub struct Vector { /* private fields */ }Expand description
A logging Service that collects log entries into an in-memory Vec.
This service is primarily used for integration testing or UI feedback loops, allowing you to capture every log generated by a specific operation and inspect them programmatically afterward.
§Thread Safety
The internal vector is protected by a Mutex. Multiple worker threads can
push logs concurrently without data races or interleaving.
Implementations§
Source§impl Vector
impl Vector
Sourcepub fn inspect_vector<R>(
&self,
f: impl FnOnce(&Vec<VectorMessage>) -> R,
) -> Option<R>
pub fn inspect_vector<R>( &self, f: impl FnOnce(&Vec<VectorMessage>) -> R, ) -> Option<R>
Sourcepub fn recover_vector(self) -> Result<Vec<VectorMessage>, ServiceError>
pub fn recover_vector(self) -> Result<Vec<VectorMessage>, ServiceError>
Consumes the service and returns all captured log messages.
This is the most efficient way to retrieve logs for final assertions or post-processing, as it extracts the data from the mutex.
§Errors
Returns ServiceError::LockPoisoned if a thread panicked while holding the lock.
Trait Implementations§
Source§impl Service for Vector
impl Service for Vector
Source§fn status(&self) -> LoggerStatus
fn status(&self) -> LoggerStatus
Returns LoggerStatus::Running.
Source§fn work(&self, msg: &Message) -> Result<(), ServiceError>
fn work(&self, msg: &Message) -> Result<(), ServiceError>
Transforms the Message into a VectorMessage and pushes it onto the internal stack.
§Errors
Returns ServiceError::LockPoisoned if the internal mutex is unreachable.
Auto Trait Implementations§
impl !Freeze for Vector
impl RefUnwindSafe for Vector
impl Send for Vector
impl Sync for Vector
impl Unpin for Vector
impl UnwindSafe for Vector
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