Very flexible Rust library for parsing syslog based on RFC 5424. Uses nom as the sole dependency.
Option<&str>
for TIMESTAMP.
And they are on pair when having the chrono-timestamp
feature on (parses TIMESTAMP
as chrono DateTime<Offset>
type).
Compared to any Ruby/Python/Js implementation is obviously an order of magnitude faster.
It's not super optimized for performance (especially around SD) and I suspect that
rust-syslog-rfc5424 is not either.
In any case, performance isn't the main goal of rsyslog. It's flexibility.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.
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.
```rust
type OneLineMessage<'a> = Message<'a, Option<&'a str>, Vec
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.