async_logging/async_logging.rs
1//! Example demonstrating non-blocking asynchronous logging.
2//!
3//! This example wraps a standard dispatcher in an `AsyncDispatcher`,
4//! ensuring that logging operations do not block the execution of your
5//! main application threads.
6
7use cirious_codex_logger::{init, warn, AsyncDispatcher, StdoutDispatcher, StyledTerminalFormatter};
8
9fn main() {
10 let stdout = Box::new(StdoutDispatcher::new(StyledTerminalFormatter));
11 let async_dispatcher = Box::new(AsyncDispatcher::new(stdout, 100));
12
13 init(async_dispatcher).ok();
14
15 warn!("This log is processed in a background thread without blocking.");
16}