Crates.io | rsyslog |
lib.rs | rsyslog |
version | 0.1.5 |
source | src |
created_at | 2021-03-17 19:53:16.365951 |
updated_at | 2024-06-11 10:21:21.378611 |
description | RFC 5424 customizable syslog parser |
homepage | |
repository | https://github.com/vasilakisfil/rsyslog |
max_upload_size | |
id | 370269 |
size | 67,554 |
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.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.
type OneLineMessage<'a> = Message<'a, Option<&'a str>, Vec<StructuredData<'a>>, 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::<Vec<_>>();
You can find more examples in the examples directory.