First Rust crate published!

Posted: 2018-09-05

I recently published my first crate syslog5424 which is a crate for formatting data into the syslog RFC5424 format. The crate can format any data type that implements the trait Rfc5424Data and then writes the formatted message to any type that implements Write.

The crate was made originally for slog so that there would be an easy way to get the structured logs from Rust into InfluxDB. Example:

Here is the example from the readme:

pub struct Rfc5424Message<'a> {
    pub severity: Severity,
    pub structured_data: Option<StructuredData<'a>>,
    pub message: Option<Message>,

impl<'a> Rfc5424Data for Rfc5424Message<'a> {
    fn severity(&self) -> Severity {

    fn timestamp(&self) -> Option<String> {

    fn structured_data(&self) -> Option<StructuredData> {

    fn message(&self) -> Option<Message> {

fn main() {
    // create the formatter struct
    let formatter = Rfc5424Builder::new("enterprise_id", Facility::User)
    // create a message to be formatted
    let mut hmap: StructuredData = HashMap::new();
            ("id".into(), "54".into()),
            ("progress".into(), "complete".into()),

    let msg = Rfc5424Message {
        severity: Severity::Error,
        structured_data: Some(hmap),
        message: Some(Message::Text("sample message. Hello there!".into())),

    // run the formatter
    let mut out = Vec::new();
    formatter.format(&mut out, &msg).unwrap();
    println!("log: {}", String::from_utf8(out).unwrap());