lucab / libsystemd-rs

A pure-Rust client library to work with systemd
https://crates.io/crates/libsystemd
Other
105 stars 19 forks source link

logging: add support for writing to journald #34

Closed jabedude closed 4 years ago

jabedude commented 4 years ago

@lucab could you please review my initial pass at adding journald logging support.

  1. I only have the core logic of forwarding messages to journald in place

  2. I am not able to pass journald a memfd and create a log entry. I've done a bit of research and only found some issues in nix with passing multiple fds, but that shouldn't matter in our case.

Close: https://github.com/lucab/libsystemd-rs/issues/32

jabedude commented 4 years ago

Got the memfd message working. It needed to have been sealed before being passed to journald.

lucab commented 4 years ago

@jabedude nice! I did a first review pass and run the tests, I got the correct output in the journal. I think sealing is not strictly required but it plays better with the receiving logic in systemd-journald, so I'm ok with doing that.

jabedude commented 4 years ago

@lucab thanks! I integrated your comments and made some small tweaks. I think the PR is ready for review!

jabedude commented 4 years ago

Sure thing

lucab commented 4 years ago

@jabedude thanks for all your work on this! This PR looks fine to me now. Is there anything else you planned to add here, or can I go ahead and merge?

jabedude commented 4 years ago

My pleasure! No, I think this is good to merge as is. I think we might want to add methods for consumers to log with arbitrary fields and data later though, but I need to look closer at sd_journal_sendv to decide on the API.