Geal / rust-syslog

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

src/format: use u32 and std::process::id not libc::getpid #49

Closed urandom2 closed 2 years ago

urandom2 commented 4 years ago

Since 0.3.2, libc::getpid is used to get the process id and store the provided id in Formatters. This has the marked side effect of being unsafe and adding an unnecessary crate dependency. As such, this change moves to using std::process::id, which likely was not stable at the time, for better stdlib integration.

Unfortunately, this is a breaking change, since the current i32s are part of the external interface, but could be implemented as compatible if the extant symbols were simply deprecated and new ones added.

Source has also been formatted and linted via rustfmt and clippy, and dependencies upgraded. Time 0.2 was held back since it incompatible with 0.1.

Fix #46

urandom2 commented 4 years ago

It was pretty hard to tell what's changed though? ... [I]t's usually good etiquette to make formatting overhauls and substantive changes completely separate, so they can be reviewed separately.

Sorry, my editor runs rustfmt by default and the clippy changes looked pretty minor. I have extracted all of both into #50.

Geal commented 2 years ago

it is a good idea. There's still one use of libc that I'll try to remove: https://github.com/Geal/rust-syslog/blob/020ccf1a8f1b05b51bd136937250f9e67f522af6/src/lib.rs#L267