gh-118868: logging QueueHandler fix passing of kwargs (GH-118869) · python/cpython@dce14bb · GitHub
Skip to content

Commit dce14bb

Browse files
Kaundurnineteendovsajip
authored
gh-118868: logging QueueHandler fix passing of kwargs (GH-118869)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com> Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
1 parent 9e05261 commit dce14bb

3 files changed

Lines changed: 39 additions & 8 deletions

File tree

Lib/logging/config.py

Lines changed: 8 additions & 8 deletions

Lib/test/test_logging.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3976,6 +3976,35 @@ def test_111615(self):
39763976
}
39773977
logging.config.dictConfig(config)
39783978

3979+
# gh-118868: check if kwargs are passed to logging QueueHandler
3980+
def test_kwargs_passing(self):
3981+
class CustomQueueHandler(logging.handlers.QueueHandler):
3982+
def __init__(self, *args, **kwargs):
3983+
super().__init__(queue.Queue())
3984+
self.custom_kwargs = kwargs
3985+
3986+
custom_kwargs = {'foo': 'bar'}
3987+
3988+
config = {
3989+
'version': 1,
3990+
'handlers': {
3991+
'custom': {
3992+
'class': CustomQueueHandler,
3993+
**custom_kwargs
3994+
},
3995+
},
3996+
'root': {
3997+
'level': 'DEBUG',
3998+
'handlers': ['custom']
3999+
}
4000+
}
4001+
4002+
logging.config.dictConfig(config)
4003+
4004+
handler = logging.getHandlerByName('custom')
4005+
self.assertEqual(handler.custom_kwargs, custom_kwargs)
4006+
4007+
39794008
class ManagerTest(BaseTest):
39804009
def test_manager_loggerclass(self):
39814010
logged = []
Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)