extern crate fern;
#[macro_use]
extern crate log;
extern crate syslog;
fn setup_logging() -> Result<(), Box<std::error::Error>> {
let syslog_fmt = syslog::Formatter3164 {
facility: syslog::Facility::LOG_USER,
hostname: None,
process: "fern-syslog-example".into(),
pid: 0,
};
fern::Dispatch::new()
.level(log::LevelFilter::Warn)
.level_for("explicit-syslog", log::LevelFilter::Info)
.chain(syslog::unix(syslog_fmt)?)
.apply()?;
Ok(())
}
fn main() {
setup_logging().expect("failed to initialize logging.");
for i in 0..5 {
info!("executing section: {}", i);
debug!("section {} 1/4 complete.", i);
debug!("section {} 1/2 complete.", i);
debug!("section {} 3/4 complete.", i);
info!("section {} completed!", i);
}
info!(target: "explicit-syslog", "hello to the syslog! this is rust.");
warn!("AHHH something's on fire.");
}