Trait lunatic_log::subscriber::Subscriber
source · 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 Event
s.
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());
}
}