7 unstable releases (3 breaking)

Uses new Rust 2021

0.4.1 Jan 23, 2022
0.4.0 Jan 18, 2022
0.3.0 Jan 18, 2022
0.2.2 Dec 30, 2021
0.1.0 Dec 19, 2021

#204 in Debugging

Download history 65/week @ 2022-06-03 15/week @ 2022-06-10 16/week @ 2022-06-17 38/week @ 2022-06-24 34/week @ 2022-07-01 46/week @ 2022-07-08 24/week @ 2022-07-15 21/week @ 2022-07-22 25/week @ 2022-07-29 7/week @ 2022-08-05 19/week @ 2022-08-12 9/week @ 2022-08-19 23/week @ 2022-08-26 37/week @ 2022-09-02 46/week @ 2022-09-09 18/week @ 2022-09-16

125 downloads per month

MIT/Apache

20KB
385 lines

Flexi-Syslog

crates.io docs.rs

A flexi-logger LogWriter that formats and transports log records to the syslog using the syslog crate.

[dependencies]
flexi_logger = "0.22"
flexi_syslog = "0.2"
syslog = "6.0"

Example Usage

fn main() {
    // syslog's Formatter5424 does not implement the rfc5424 timestamp correctly
    let formatter = flexi_syslog::Formatter5424 {
        facility: syslog::Facility::LOG_USER,
        hostname: None,
        process: "basic".into(),
        pid: 0,
    };

    let sys_logger = syslog::unix(formatter).expect("Failed to init unix socket");

    let syslog_writer = flexi_syslog::log_writer::Builder::default()
        .max_log_level(log::LevelFilter::Info)
        .build(sys_logger);

    let logger = flexi_logger::Logger::try_with_str("info")
        .expect("Failed to init logger")
        .log_to_writer(Box::new(syslog_writer));

    let handle = logger.start().expect("Failed to start logger");

    log::info!("Info gets through");
    log::trace!("Trace is filtered");

    handle.flush();
}

Dependencies

~1.2–1.8MB
~36K SLoC