[Yum-devel] Logging (no excitement)

Tim Lauridsen tim at rasmil.dk
Wed May 31 15:53:01 UTC 2006


James Bowes wrote:
> Hi all:
>
> 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.
>
>
> -James
I dont know if this patch is the right way to go, it breaks the logging 
in the yum API, Programs using the API like yumex overloads the
log, error, filelog methods in yumbase to redirect the log output fx. to 
a TextView, other application build on the yum API. yum utils, pup, 
pirut might be affected too.
A better way to implement this kind of logging is to build some kind of 
wrapper there translates the log,erorlog,filelog into python logging. 
Then the API will not be broken.

Tim
Yumex Developer



More information about the Yum-devel mailing list