1- # Copyright 2001-2013 by Vinay Sajip. All Rights Reserved.
1+ # Copyright 2001-2015 by Vinay Sajip. All Rights Reserved.
22#
33# Permission to use, copy, modify, and distribute this software and its
44# documentation for any purpose and without fee is hereby granted,
1818Additional handlers for the logging package for Python. The core package is
1919based on PEP 282 and comments thereto in comp.lang.python.
2020
21- Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved.
21+ Copyright (C) 2001-2015 Vinay Sajip. All Rights Reserved.
2222
2323To use, simply 'import logging.handlers' and log away!
2424"""
@@ -1350,7 +1350,7 @@ class QueueListener(object):
13501350 """
13511351 _sentinel = None
13521352
1353- def __init__ (self , queue , * handlers ):
1353+ def __init__ (self , queue , * handlers , respect_handler_level = False ):
13541354 """
13551355 Initialise an instance with the specified queue and
13561356 handlers.
@@ -1359,6 +1359,7 @@ def __init__(self, queue, *handlers):
13591359 self .handlers = handlers
13601360 self ._stop = threading .Event ()
13611361 self ._thread = None
1362+ self .respect_handler_level = respect_handler_level
13621363
13631364 def dequeue (self , block ):
13641365 """
@@ -1399,7 +1400,12 @@ def handle(self, record):
13991400 """
14001401 record = self .prepare (record )
14011402 for handler in self .handlers :
1402- handler .handle (record )
1403+ if not self .respect_handler_level :
1404+ process = True
1405+ else :
1406+ process = record .levelno >= handler .level
1407+ if process :
1408+ handler .handle (record )
14031409
14041410 def _monitor (self ):
14051411 """
0 commit comments