[Yum-devel] Logging (no excitement)
jbowes at redhat.com
Tue May 30 15:38:46 UTC 2006
Attached is a patch to move yum from using a custom logging
implementation to python's logging module.
A few notes about the patch:
There are three logging 'areas' - yum, yum.verbose, and yum.filelogging.
yum logs to stderr, yum.verbose logs to stdin, and filelogging logs to a
file/syslog. Each object has a logger under one or more of these areas.
Each class was basically modified in the following ways -
* Create 1 or more logger member variables in __init__()
* replace all self.log with self.logger.log|warn|debug etc as appropriate.
Logging configuration is different from what was first planned. Ideally,
the logging config would have lived in yum's config file in the native
logging format. Both yum and logging didn't like reading each other's
configs and threw exceptions. Even with the logging config in its own
file, there were two issues. First, there was no way to properly handle
the /var/log/ log file when the user was not root. Second, when the
configuration was loaded, it would disable all previously instantiated
loggers, so a lot of the logger messages would be lost. In the end, I
did the logging configuration programmatically.
The interesting part of the patch is at the end; the logginglevels.py
file. This file defines the additional logging levels yum needs,
provides functions for converting from the old logger.py 0-10 levels to
the new python logging levels, and contains the method to set up logging.
The patch doesn't include any changes to yum-updatesd.py, and there's
also the C repomd parser, but it shouldn't take to much to patch those up.
The new logging calls are a little more verbose than the old ones
(especially when a yum-specific level is used). I was a little worried
that this, along with the logginglevels.py file, would end up increasing
the amount of code in yum. Since logger.py can be removed, we should end
up with a net decrease. Not that lines of code are all that matters.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 112553 bytes
Desc: not available
Url : http://lists.baseurl.org/pipermail/yum-devel/attachments/20060530/a1afd88f/attachment.bin
More information about the Yum-devel