pub struct AsyncDispatcher { /* private fields */ }Expand description
A dispatcher that offloads log processing to a background thread.
Implementations§
Source§impl AsyncDispatcher
impl AsyncDispatcher
Sourcepub fn new(
dispatcher: Box<dyn Dispatcher + Send + Sync>,
buffer_size: usize,
) -> Self
pub fn new( dispatcher: Box<dyn Dispatcher + Send + Sync>, buffer_size: usize, ) -> Self
Creates a new AsyncDispatcher that wraps the provided dispatcher.
This constructor spawns a dedicated background thread that manages log dispatching. All log records sent to this dispatcher are queued in an internal bounded channel before being processed asynchronously.
§Arguments
dispatcher- The underlyingDispatcherresponsible for the actual output (e.g., writing to a file or standard streams).buffer_size- The maximum capacity of the internal channel. When the buffer is full, logging threads will block until space becomes available (backpressure).
§Panics
This method will panic if the operating system fails to spawn the background OS thread.
§Example
use cirious_codex_logger::{AsyncDispatcher, StdoutDispatcher, StyledTerminalFormatter};
let stdout_dispatcher = Box::new(StdoutDispatcher::new(StyledTerminalFormatter));
let async_dispatcher = AsyncDispatcher::new(stdout_dispatcher, 1024);Trait Implementations§
Source§impl Debug for AsyncDispatcher
impl Debug for AsyncDispatcher
Source§impl Dispatcher for AsyncDispatcher
impl Dispatcher for AsyncDispatcher
Auto Trait Implementations§
impl Freeze for AsyncDispatcher
impl RefUnwindSafe for AsyncDispatcher
impl Send for AsyncDispatcher
impl Sync for AsyncDispatcher
impl Unpin for AsyncDispatcher
impl UnsafeUnpin for AsyncDispatcher
impl UnwindSafe for AsyncDispatcher
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
Mutably borrows from an owned value. Read more