Function lunatic_log::init
source · pub fn init(subscriber: impl Subscriber) -> Process<Event>
Expand description
Initialize a subscriber to handle log events.
The subscriber is spawned in a lunatic::Process
and receives log events.
Examples found in repository?
More examples
examples/pretty.rs (line 5)
3 4 5 6 7 8 9 10 11 12 13 14 15 16
fn main() {
// Initialize subscriber
lunatic_log::init(FmtSubscriber::new(LevelFilter::Trace).pretty());
// Log message
error!("Error");
warn!("Warn");
info!("Info");
debug!("Debug");
trace!("Trace");
// Wait for events to propagate
lunatic::sleep(std::time::Duration::from_millis(50));
}
examples/multiple.rs (line 14)
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));
}