pub trait Subscriber: Serialize + DeserializeOwned {
    // Required methods
    fn enabled(&self, metadata: &Metadata) -> bool;
    fn event(&self, event: &Event);
}
Expand description

A subscriber which handles incoming log Events.

Example

#[derive(Serialize, Deserialize)]
pub struct FmtSubscriber {
    level_filter: LevelFilter,
}

impl Subscriber for FmtSubscriber {
    fn enabled(&self, metadata: &Metadata) -> bool {
        metadata.level() <= &self.level_filter
    }

    fn event(&self, event: &Event) {
        println!("Log: {}", event.message());
    }
}

Required Methods§

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.

Implementors§