What steps will reproduce the problem?
- Create handler with ERROR log level.
- Add it to
QueueListener
. - Create logger with
QueueHandler
which will communicate with listener. - Try to log with lower level - for example DEBUG.
What is the expected output? What do you see instead?
Log messages are logged by handler, but I would expect that they are filtered out by QueueListener
and passed only to appropriate handlers.
What version of the product are you using? On what operating system?
versions: logutils == 0.3.3, python == 2.7 os: GNU/Linux
Additional comment:
I'm not sure if this is a bug or design decision - QueueListener.handle
method ignores handlers log levels:
def handle(self, record):
record = self.prepare(record)
for handler in self.handlers:
handler.handle(record)
In contrast logger logging.Logger.callHandlers
method (which is called directly from handle
method), uses handlers levels to filter out only those with appropriate configuration:
def callHandlers(self, record):
...
while c:
for hdlr in c.handlers:
found = found + 1
if record.levelno >= hdlr.level:
hdlr.handle(record)
...
This behavior is especially needed in deployment debugging phase - I want to log everything to file, but receive only error information on email.
Should I override handle
method myself and reimplement above logic or should I expect that this behavior will be changed in library?
Comment #1
Posted on Mar 1, 2014 by Swift LionSorry for the delay in replying - I never got an email notification about this issue from Google Code, and stumbled on it by chance just now.
The behaviour is by design - the events are supposed to be filtered at the source level (in the QueueHandler which feeds the queue). Of course you are free to subclass and override, but I'm not currently planning to change the base class behaviour.
Comment #2
Posted on Mar 1, 2014 by Happy WombatOk, I understand. Thanks for your reply and great lib!
Status: Invalid
Labels:
Type-Defect
Priority-Medium