mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-93162: Add ability to configure QueueHandler/QueueListener together (GH-93269)
Also, provide getHandlerByName() and getHandlerNames() APIs. Closes #93162.
This commit is contained in:
parent
c6f6ede728
commit
1b74803991
8 changed files with 325 additions and 31 deletions
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2001-2019 by Vinay Sajip. All Rights Reserved.
|
||||
# Copyright 2001-2022 by Vinay Sajip. All Rights Reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software and its
|
||||
# documentation for any purpose and without fee is hereby granted,
|
||||
|
@ -18,7 +18,7 @@
|
|||
Logging package for Python. Based on PEP 282 and comments thereto in
|
||||
comp.lang.python.
|
||||
|
||||
Copyright (C) 2001-2019 Vinay Sajip. All Rights Reserved.
|
||||
Copyright (C) 2001-2022 Vinay Sajip. All Rights Reserved.
|
||||
|
||||
To use, simply 'import logging' and log away!
|
||||
"""
|
||||
|
@ -38,7 +38,8 @@ __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR',
|
|||
'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
|
||||
'info', 'log', 'makeLogRecord', 'setLoggerClass', 'shutdown',
|
||||
'warn', 'warning', 'getLogRecordFactory', 'setLogRecordFactory',
|
||||
'lastResort', 'raiseExceptions', 'getLevelNamesMapping']
|
||||
'lastResort', 'raiseExceptions', 'getLevelNamesMapping',
|
||||
'getHandlerByName', 'getHandlerNames']
|
||||
|
||||
import threading
|
||||
|
||||
|
@ -885,6 +886,23 @@ def _addHandlerRef(handler):
|
|||
finally:
|
||||
_releaseLock()
|
||||
|
||||
|
||||
def getHandlerByName(name):
|
||||
"""
|
||||
Get a handler with the specified *name*, or None if there isn't one with
|
||||
that name.
|
||||
"""
|
||||
return _handlers.get(name)
|
||||
|
||||
|
||||
def getHandlerNames():
|
||||
"""
|
||||
Return all known handler names as an immutable set.
|
||||
"""
|
||||
result = set(_handlers.keys())
|
||||
return frozenset(result)
|
||||
|
||||
|
||||
class Handler(Filterer):
|
||||
"""
|
||||
Handler instances dispatch logging events to specific destinations.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue