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

source

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));
}
source

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

source§

fn default() -> MultipleSubscribers

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for MultipleSubscribers

source§

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

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Subscriber for MultipleSubscribers

source§

fn enabled(&self, _metadata: &Metadata) -> bool

Indicate whether subscriber is enabled given some Metadata.
source§

fn event(&self, event: &Event)

Handle a log Event.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,