Geal / rust-syslog

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

Proposal: allow compilation on systems without UNIX sockets #43

Closed Robertof closed 4 years ago

Robertof commented 5 years ago

Right now the module includes std::os::unix::net to support UNIX sockets, however this core module is not built at all on non-UNIX platforms (e.g. Windows). The module should still be able to function though, with the TCP and UDP backends.

One idea to add #[cfg(unix)] before std::os::unix::net, add a new error kind "UnsupportedPlatform" and return that error when functions such as unix are called from within unsupported platforms.

I have implemented something like that here: https://github.com/Robertof/rust-syslog/commit/bffd3a3cb06dc9ca4af77e9b94aab97928c3b3f9

If this looks good to you, I can make a PR.

Thanks, Roberto

Kromey commented 5 years ago

This would be a very valuable feature in mixed environments like ours with both Linux and Windows hosts, and which have a central syslog server. I was hoping to ship logs directly from my Rust program, but compilation of course fails on Windows. For now it's back to local log files, sadly.

Robertof commented 5 years ago

Hey @Kromey, as I said in the issue, I made a (proposed) patch to my branch to solve this. If you need the feature and you'd like to try it, just add the following to your Cargo.toml:

[patch.crates-io]
syslog = { git = "https://github.com/Robertof/rust-syslog" }
Kromey commented 5 years ago

I fully intend to try your patch @Robertof, but yesterday I needed the project out the door before requirements shifted under me again, and honestly didn't think to check the issues (or file one myself) until I'd already ditched syslog and returned to my local files. Unfortunately I need to shift gears and get another issue on an unrelated project taken care of, but I'll be back in a few days or so to try your fix.

Geal commented 4 years ago

@Robertof the patch looks fine, I imported it as 8e4c611. Sorry for the delay