Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support message ids as strings #82

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ctrlaltf24
Copy link
Contributor

MSGID examples in rfc 5424 are strings

For example, a firewall might use the MSGID "TCPIN" for incoming TCP traffic and the MSGID "TCPOUT" for outgoing TCP traffic.

  • rfc 5424

Unsure how you want to handle validating the message_id's input. The current implementation has the easiest to interact with API boundary, but at the cost of runtime cycles.

message id is likely a constant possibly called many times, we could add an option to run the validation once using a wrapper type, then use it safely per call

) -> Result<()> {
let (message_id, data, message) = log_message;

// XXX: seems a lot of effort per-call, we could do this via a wrapper type instead
Copy link
Contributor Author

@ctrlaltf24 ctrlaltf24 May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts? Is this OK or would you prefer a wrapper type? Or both?

I implemented such a wrapper type here: ctrlaltf24@7f0b138 seemed to add more complexity than it's worth.

Comment on lines +178 to +184
.filter(is_us_print_ascii)
.take(32)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also validate more of these fields to prevent the user from giving us values that violate the rfc, but at a runtime cost (as I've implemented here) ctrlaltf24@0362d74#diff-c875d3cb38acba1839738726b3d4aa920bec536459b52d5bc5069a91dd1620f5R187-R218 . Not sure if you'd want those changes, assuming no since the additional runtime complexity

MSGID examples in rfc 5424 are strings

> For example, a firewall might use the MSGID "TCPIN" for incoming TCP traffic and the MSGID "TCPOUT" for outgoing TCP traffic.
- rfc 5424

Unsure how you want to handle validating the message_id's input.
The current implementation has the easiest to interact with API boundary, but at the cost of runtime cycles.

message id is likely a constant possibly called many times, we could add an option to run the validation once
using a wrapper type, then use it safely per call
@ctrlaltf24 ctrlaltf24 force-pushed the feat-support-message-id-as-strings branch from 9e676fb to 568d4e5 Compare May 10, 2024 21:38
@tisonkun
Copy link

FWIW I made a syslog library https://github.com/fast/fasyslog/ that implements similar functionality as well as MSGID as strings.

See https://docs.rs/fasyslog/latest/fasyslog/sender/enum.SyslogSender.html#method.send_rfc5424

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants