Geal / rust-syslog

Send syslog messages from Rust
MIT License
109 stars 55 forks source link

Documentation: Please provide an example on how to make it work with the log crate #45

Closed axos88 closed 4 years ago

JayKickliter commented 5 years ago

Seconded. Maybe it's obvious to some, but I get it.

axos88 commented 5 years ago

I wound up using this:

    let formatter = syslog::Formatter3164 {
        facility: syslog::Facility::LOG_DAEMON,
        hostname: None,
        process: "xxxx".into(),
        pid: std::process::id() as i32,
    };

    let inner = syslog::unix(formatter).expect("could not connect to syslog");
    let inner = syslog_logger::SyslogLogger::new(inner);

    // Actually I'm wrapping this in my own implementation that adds a few extra bells and whistles, but this should also work:
     log::set_boxed_logger(Box::new(inner))
Geal commented 4 years ago

thanks, I just added an example with the log crate in 54727a7