emabee / flexi_logger

A flexible logger for rust programs that can write to stderr, stdout, and/or to log files
Apache License 2.0
307 stars 50 forks source link

Syslog Unix Family Fixes #103

Closed bheylin closed 2 years ago

bheylin commented 2 years ago

I'm trying to get the experimental syslog_writer feature up and running on FreeBSD, Linux and OSX and noticed a few issues straight away. I'm opening this PR to fix the various issues I come across as I test.

The first issue is that the cfg(target_os) conditional used in the syslog_writer mod is restricted to Linux even through syslog is a Unix family standard.

This overly strict Linux restriction is something I noticed in general across flexi-logger, but I refrained from making a cross project change at this time, given that my concern is getting syslog up and running.

The second issue is that the writeln! macro used in impl LogWriter for SyslogWriter is submitting a syslog entry for each formatting placeholder. This issue will be resolved in an upcoming commit.

emabee commented 2 years ago

Thanks a lot for the careful work here! Once done with the code, please revise also the README section on the syslog feature.

emabee commented 2 years ago

I agree with your statement on the use of target_os="linux". I definitely should revise that, too.

bheylin commented 2 years ago

Hey @emabee I've got a syslog implementation through libc that I've just tested on a private project. I'd also like to integrate that into flexi-logger but I'll do that in a separate PR. I've found that the current syslog impl through a datagram connection results in duplicate information in the log message. I'm favoring the libc impl atm as it work as expected.

bheylin commented 2 years ago

Thanks a lot for the careful work here! Once done with the code, please revise also the README section on the syslog feature.

I think the README is still accurate.

This is still an experimental feature, likely working, but not well tested. Feedback of all kinds is highly appreciated.

This PR doesn't fix the syslog impl, it makes it less broken. The logging through the datagram connection is still not working correctly. Text is logged but not in the correct format.

bheylin commented 2 years ago

Any chance of getting this merged into main?

bheylin commented 2 years ago

I've made a libc implementation of a syslog writer to flexi-logger.

https://crates.io/crates/flexi_syslog

Maybe we can merge it into flexi-logger someday.

emabee commented 2 years ago

Thanks for the PR! It's merged now in master. Since I added some modifications it would be great if you could retest your scenario with it before I publish the new version.