Geal / rust-syslog

Send syslog messages from Rust
MIT License
109 stars 55 forks source link

Support unix-stream transparently #22

Closed vorner closed 7 years ago

vorner commented 7 years ago

Hello

I have some systems that have /dev/log as a stream socket, not a datagram one. The C's syslog function is able to cope with that and works out of the box, so I'd appreciate the same support from Rust.

The change should be backwards compatible ‒ it first checks the dgram and if it is refused with a EPROTOTYPE (wrong protocol type), it tries stream as well.

I'm not entirely sure about the code style ‒ are 2 or 4 spaces used? Should I try providing some test?

If you like it and merge it, would it be OK to make a release (hopefully with only minor version bumped, so dependent crates can work with it right away)?

Roguelazer commented 7 years ago

this would be super-helpful

Roguelazer commented 7 years ago

Actually, @vorner, it appears that (at least for syslog-ng), subsequent messages on a stream-mode domain socket need to be separated by null bytes. This behavior is implemented in, e.g., logger(1).

vorner commented 7 years ago

Ups, sorry. Maybe I should have tried with more than a single message.

OK, I'll look into it soon.

Geal commented 7 years ago

ok, so, I'll merge this now, then I'll go on doing the big refactoring this library needs. @vorner is it fine if I just append a null byte to whatever is sent to the stream? Maybe this will need some buffering at some point

vorner commented 7 years ago

Thank you.

If you asked if it was OK with me altering the commit, then yes, of course. If you asked if it would work properly, then I don't know, I planned to find the time to look into it over the weekend.

Anyway, I'll at least test it and see how it works in practice.