-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework using the POSIX syslog API #6
base: master
Are you sure you want to change the base?
Conversation
As discussed in PR slog-rs#5, this is based on the [syslog backend that I wrote for sloggers][1] and does not use the `syslog` crate. It is now very different from both slog-syslog 0.12 and PR slog-rs#5. Differences from slog-rs#5 include: * Uses the POSIX syslog API through the `libc` crate. (See “design and rationale” in src/lib.rs, starting at line 52, for details.) This means: * Only works on Unix-like platforms. * Only sends log messages to the local syslog daemon, not to a remote server. * Formats log messages into a reusable thread-local buffer, as in slog-syslog 0.12. * The `Drain` implementation is now called `SyslogDrain` instead of `Streamer3164`, since local syslog doesn't use the RFC3164 protocol. * If the `serde` feature is enabled, logging settings can be loaded from a configuration file. Minimum supported Rust version is 1.27.2, or if the `serde` feature is enabled, 1.31.0. Doc-tests require 1.28.0. Works (except doc-tests) on 1.26.2 if you run the following commands first: ``` cargo generate-lockfile cargo update --package lazy_static --precise 1.3.0 cargo update --package serde --precise 1.0.58 cargo update --package serde_derive --precise 1.0.58 ``` [1]: sile/sloggers#34
Thank you so much for this, works on linux for me, but on macOS it just doesn't log anything. I did spend some time to figure out why but didn't find any issues at first glance. But macOS syslog also doesn't work with original slog-syslog, which outputs this for every log statement: |
Strange. I just got ahold of a Mac and tested this, and it worked for me. One of the doc-tests emits an actual log message, and that message did indeed appear in the Mac Console app. It was pretty hard to spot among all the log messages that macOS itself generates, but it was there. If you're sure it's not working for you, could you try running |
I think what I didn't see is that only error!() and warn!() logs are printed, but not info nor debug!
I will check on how to configure this after my vacation. So far everything is fine for me. |
On macOS all info/debug syslog messages are dropped by default, they can be enabled using a configuration file in /etc/asl.conf . I found out after I added support for setlogmask, in case you want to use it: argv-minus-one#1 |
I made a proper pull request that solves everything for me argv-minus-one#2 |
… a given syslog priority
…n a per-message basis. Thanks to @eun-ice for the idea and initial implementation.
What happened to this work? |
@reyk There doesn't seem to be much interest from the maintainers. |
Your approach to use POSIX would actually make it more portable 👍 You can argue about support for sending to remote syslog servers without going through syslog, but for local syslog it is much better to rely on libc because the underlying API might be different. For example, this crate does not work on systems that use the sendsyslog(2) system call instead of the classic syslog UNIX socket. sendsyslog is an improvement because it provides a reliable kernel-backed queue and because it works inside of a sandbox/chroot (https://man.openbsd.org/sendsyslog). |
This PR reworks slog-syslog to use the POSIX syslog API. It is a breaking change. Supersedes PR #5.
As discussed in PR #5, this is based on the syslog backend that I wrote for sloggers and does not use the
syslog
crate. It is now very different from both slog-syslog 0.12 and PR #5. Differences from #5 include:libc
crate. (See “design and rationale” in src/lib.rs, starting at line 52, for details.) This means:Drain
implementation is now calledSyslogDrain
instead ofStreamer3164
, since local syslog doesn't use the RFC3164 protocol.serde
feature is enabled, logging settings can be loaded from a configuration file.Minimum supported Rust version is 1.27.2, or if the
serde
feature is enabled, 1.31.0. Doc-tests require 1.28.0. Works (except doc-tests) on 1.26.2 if you run the following commands first: