This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author leorochael
Recipients leorochael
Date 2009-12-17.18:52:12
SpamBayes Score 1.1513517e-08
Marked as misclassified No
Message-id <1261075935.27.0.779288069051.issue7535@psf.upfronthosting.co.za>
In-reply-to
Content
A filter added to, say, logging.getLogger('a').addFilter() never gets
the chance to filter messages logged into logging.getLogger('a.b').

On logging.Logger.handle() the current logger filters are called to
check if the message should be processed or not, but the logger parent
filters are not consulted (and this is ok, IMHO, more generic filters
shouldn't clobber messages of more specific loggers).

However, if none of the current filters block the message,
Logger.handle() then calls Logger.callHandlers(), which calls the
handlers of the current logger and of all the parent loggers as long as
each logger in the hierarchy allows the message to propagate. This is
done without consulting the parent loggers filters.

This means parent handlers get called to process log records even if the
parent logger filters would have otherwise blocked them.

Attached is a very crude patch that allows the parent loggers to filter
events before handling them. I'd prefer to simply call the "handle()" 
or "callHandler()" method of the parent loggers recursively, but
couldn't find a way to do this while still preserving the method
signatures AND properly reporting when no handler could be found.

My preference would be to have callHandlers() do the filtering AND
return a number of handlers invoked, including the parent handlers, so
that handle() could report if no handlers could be found.
History
Date User Action Args
2009-12-17 18:52:15leorochaelsetrecipients: + leorochael
2009-12-17 18:52:15leorochaelsetmessageid: <1261075935.27.0.779288069051.issue7535@psf.upfronthosting.co.za>
2009-12-17 18:52:13leorochaellinkissue7535 messages
2009-12-17 18:52:12leorochaelcreate