pub struct Vector { /* private fields */ }Expand description
A factory for creating loggers that store messages in an in-memory Vec.
The Vector factory is ideal for unit testing, allowing you to capture
logs in a thread-safe list and verify them later. Unlike string-based loggers,
this preserves the structured Message data.
§Default Configuration
- Capacity:
1024(Pre-allocated slots for log messages). - Max Retries:
3(Attempts to re-send if the buffer is temporarily locked). - Worker Count:
1(Ensures sequential insertion order in async mode).
Implementations§
Source§impl Vector
impl Vector
Sourcepub fn new(capacity: usize, max_retries: usize, worker_count: usize) -> Self
pub fn new(capacity: usize, max_retries: usize, worker_count: usize) -> Self
Creates a new Vector factory with explicit settings.
Sourcepub fn get_capacity(&self) -> usize
pub fn get_capacity(&self) -> usize
Returns the initial pre-allocated capacity for the message buffer.
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 capacity(self, capacity: usize) -> Self
pub fn capacity(self, capacity: usize) -> Self
Sets the initial capacity of the internal vector.
Pre-allocating capacity helps avoid expensive reallocations during high-frequency logging events.
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 buffer.
Sourcepub fn worker_count(self, worker_count: usize) -> Self
pub fn worker_count(self, worker_count: usize) -> Self
Updates the background worker count.
Note: Using multiple workers with a vector may result in logs being inserted out of chronological order.
Sourcepub fn build(self, concurrency: Concurrency) -> Logger
pub fn build(self, concurrency: Concurrency) -> Logger
Finalizes the builder and returns a high-level Logger.
Sourcepub fn build_impl_direct(self) -> Box<DirectLogger>
pub fn build_impl_direct(self) -> Box<DirectLogger>
Builds the underlying DirectLogger implementation.
Sourcepub fn build_impl_queued(self) -> Box<QueuedLogger>
pub fn build_impl_queued(self) -> Box<QueuedLogger>
Builds the underlying QueuedLogger implementation.
Sourcepub fn build_service(self) -> Box<Vector>
pub fn build_service(self) -> Box<Vector>
Internal helper to construct the service::Vector instance.
Trait Implementations§
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