Rsyslog

Very flexible Rust library for parsing syslog based on RFC 5424. Uses nom as the sole dependency.

Features

Cargo features

Optional features: * chrono-timestamp: Allows you to parse TIMESTAMP as Option<chrono::DateTime<chrono::FixedOffset>>. * serde-serialize: Allows you to serialize the Message struct using serde.

Example of usage

Simple message

rust let msg = r#"<29>1 2016-02-21T04:32:57+00:00 web1 someservice - - [origin x-service="someservice"][meta sequenceId="14125553"] 127.0.0.1 - - 1456029177 "GET /v1/ok HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575"#; let message: Message = rsyslog::Message::parse(msg)?;

By default Message type is Message<'a, Option<&'a str>, Vec<StructuredData>, Raw<'a>> using default generic type params.

Multiline message

```rust type OneLineMessage<'a> = Message<'a, Option<&'a str>, Vec>, LineRaw<'a>>;

let msg = r#"<29>1 2016-02-21T04:32:57+00:00 web1 someservice - - - 127.0.0.1 - - 1456029177 "GET /v1/info HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575 <29>1 2016-02-21T05:32:57+00:00 web2 someservice - - - 127.0.0.1 - - 1456029177 "GET /v1/videos HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575 <29>1 2016-02-21T06:32:57+00:00 web3 someservice - - - 127.0.0.1 - - 1456029177 "GET /v1/users HTTP/1.1" 200 145 "-" "hacheck 0.9.0" 24306 127.0.0.1:40124 575"#;

let hostnames = OneLineMessage::iter(msg) .map(|s| s.map(|s| s.hostname)) .collect::>(); ```

You can find more examples in the examples directory.