-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Consider adding logging.handlers.LocalSysLogHandler #96339
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
Comments
Isn't there also a potential thread-safety issue in how the |
Not as far as I know. Syslog(3) should be thread safe (according to POSIX), and the code in Modules/syslog.c looks fine to me. It is possible to introduce threading issues by emulating to much of SysLogHandler because of the process global configuration of syslog(3). It's probably best to not have a configuration option for setting the "ident", but let users set this value through the syslog module if they need to change it, and likewise for the syslog options (like LOG_NDELAY). E.g., don't call |
How about adding it as a separate project on PyPI, rather than adding to the stdlib now? It's only really for users of new macOS versions. |
Why not add it to the stdlib? That way we can tell users to use the new handler to log locally. "Users of new macOS versions" will be "everyone on macOS that want to log to the system logs" in a couple of years. I can create a PR for this. Alternatively update the SysLogHandler to use the syslog module when instantiated using the default log target, but that could lead to subtle behaviour changes and would unnecessarily complicate the implementation. |
My main concern is that I don't use macOS, don't have access to a macOS machine and so might have difficulty supporting this addition. |
Perhaps you could add this suggestion to the "Core development" category on Discourse? I'd like to get other core devs' opinions on this, too. |
This is not a macOS specific feature, the handler would work on every system supported by the syslog module, which is basically any unix-y system including Linux.
I'll do that over the weekend. |
I finally got around to posting about this: https://discuss.python.org/t/logging-hander-using-the-syslog-module/18993. Sorry about the delay. |
Feature or enhancement
Add a handler to the logging package that uses
syslog.syslog
to logPitch
As mentioned in #91070 the
logging.handlers.SysLogHandler
cannot log to the local system log on recent versions of macOS. It is possible to log usingsyslog.syslog
, I've checked that the code below results in a message in the system log:Because of this it might be useful to define a
LocalSysLogHander
class that logs locally using thesyslog
module.There is a design challenge here though: The syslog module (and libc function) has proces global configuration. This in particular affects the "ident" field which can only be set as proces global configuration. Another challenge is the interaction between the logging package handling of priorities and handling of those in
syslog(3)
.The text was updated successfully, but these errors were encountered: