pub fn unix<F: Clone>(_formatter: F) -> Result<Logger<LoggerBackend, F>>
Examples found in repository?
examples/log.rs (line 17)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
fn main() {
let formatter = Formatter3164 {
facility: Facility::LOG_USER,
hostname: None,
process: "myprogram".into(),
pid: 0,
};
let logger = syslog::unix(formatter).expect("could not connect to syslog");
log::set_boxed_logger(Box::new(BasicLogger::new(logger)))
.map(|()| log::set_max_level(LevelFilter::Info))
.expect("could not register logger");
info!("hello world");
}
More examples
examples/rfc5424.rs (line 14)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
fn main() {
let formatter = Formatter5424 {
facility: Facility::LOG_USER,
hostname: None,
process: "myprogram".into(),
pid: 0,
};
match syslog::unix(formatter) {
Err(e) => println!("impossible to connect to syslog: {:?}", e),
Ok(mut writer) => {
writer
.err((1, HashMap::new(), "hello world"))
.expect("could not write error message");
}
}
}
examples/write.rs (line 13)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
fn main() {
let formatter = Formatter3164 {
facility: Facility::LOG_USER,
hostname: None,
process: "myprogram".into(),
pid: 0,
};
match syslog::unix(formatter) {
Err(e) => println!("impossible to connect to syslog: {:?}", e),
Ok(mut writer) => {
writer
.err("hello world")
.expect("could not write error message");
writer
.err("hello all".to_string())
.expect("could not write error message");
}
}
}