[Yum-devel] Syslog issues
Ville Skyttä
ville.skytta at iki.fi
Mon Mar 22 19:50:50 UTC 2010
Hello,
I looked into making syslog_ident, syslog_facility and syslog_device
configurable and documented, but now I think things are pretty broken. Here's
how I understand things at the moment:
yum uses logging.handlers.SysLogHandler for syslog logging and tries to set
ident and facility by invoking syslog.openlog() to set the defaults. That has
no effect because logging.handlers.SysLogHandler doesn't use the syslog module
at all, it writes directly to sockets -- the default settings from openlog()
apply only to syslog() calls.
Now, logging.handlers.SysLogHandler can take the facility in its constructor,
but oh joy: it doesn't use the constants from the syslog module, it works with
its internal logging.handlers.SysLogHandler.LOG_USER etc constants or its
internal string mapping to them ("user" -> LOG_USER etc). Both are
undocumented :P. It *seems* that one can get from the syslog constants to the
SysLogHandler-understood ones with >> 3, e.g. syslog.LOG_USER >> 3 ==
SysLogHandler.LOG_USER.
Regarding ident, it seems that SysLogHandler doesn't deal with it at all, it
just uses strings. logginglevels' syslogformatter tries to deal with it, but
the formatters are bad because they do strings like "yum: $MESSAGE" or
"yum($APP): $MESSAGE" (if setLoggingApp() was used) but AFAIU the messages for
raw syslog access like SysLogHandler does them should look e.g. like
"$TIMESTAMP $HOSTNAME $IDENT[$PID]: $MESSAGE" per RFC 3164 (ignoring the
leading <XXX> for now, that's taken care of by SysLogHandler).
Regarding the device, syslog_device works as expected.
How about fixing/improving things like this:
1) Make syslog_device take either a host:port string or a path to a device
like it currently does. Empty string (or None) disables syslog logging, so
does a path to a nonexistent file (like currently). host:port gets split into
a tuple so that it can be fed to the SysLogHandler constructor.
2) Trust that syslog.LOG_FOO >> 3 yields a facility value with which
SysLogHandler does the right thing, and use those in SysLogHandler constructor
(i.e. modify _syslog_facility_map to contain these >> 3 ones).
3a) Apply syslog_ident to the syslog formatter in logginglevels.
...or:
3b) Completely ignore syslog_ident, there's already
logginglevels.setLoggingApp().
4) Fix the syslog formatters to produce strings like "$TIMESTAMP $HOSTNAME
$APP[$PID]: $MESSAGE".
...or forget about logging.handlers.SysLogHandler, ditch syslog_device, and
use the syslog module directly.
Thoughts?
More information about the Yum-devel
mailing list