Struct lunatic_log::subscriber::multiple::MultipleSubscribers
source · pub struct MultipleSubscribers { /* private fields */ }
Expand description
Combines multiple subscribers into a single subscriber.
Child subscriber processes are spawned, and each one is notified of incoming events.
Implementations§
source§impl MultipleSubscribers
impl MultipleSubscribers
sourcepub fn new() -> Self
pub fn new() -> Self
Creates an instance of MultipleSubscribers
.
Examples found in repository?
examples/multiple.rs (line 9)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
fn main() {
// Setup multiple subscribers
let subscriber = MultipleSubscribers::new()
.add_subscriber(FmtSubscriber::new(LevelFilter::Info))
.add_subscriber(FmtSubscriber::new(LevelFilter::Info));
// Initialize multiple subscribers
lunatic_log::init(subscriber);
// Log message
info!("Hello, {}", "World");
// Wait for events to propagate
lunatic::sleep(std::time::Duration::from_millis(50));
}
sourcepub fn add_subscriber(self, subscriber: impl Subscriber) -> Self
pub fn add_subscriber(self, subscriber: impl Subscriber) -> Self
Adds a child subscriber which runs in its own process.
Examples found in repository?
examples/multiple.rs (line 10)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
fn main() {
// Setup multiple subscribers
let subscriber = MultipleSubscribers::new()
.add_subscriber(FmtSubscriber::new(LevelFilter::Info))
.add_subscriber(FmtSubscriber::new(LevelFilter::Info));
// Initialize multiple subscribers
lunatic_log::init(subscriber);
// Log message
info!("Hello, {}", "World");
// Wait for events to propagate
lunatic::sleep(std::time::Duration::from_millis(50));
}
Trait Implementations§
source§impl Default for MultipleSubscribers
impl Default for MultipleSubscribers
source§fn default() -> MultipleSubscribers
fn default() -> MultipleSubscribers
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for MultipleSubscribers
impl<'de> Deserialize<'de> for MultipleSubscribers
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Serialize for MultipleSubscribers
impl Serialize for MultipleSubscribers
Auto Trait Implementations§
impl RefUnwindSafe for MultipleSubscribers
impl Send for MultipleSubscribers
impl Sync for MultipleSubscribers
impl Unpin for MultipleSubscribers
impl UnwindSafe for MultipleSubscribers
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