summaryrefslogtreecommitdiffstats
path: root/Lib/logging/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/logging/__init__.py')
-rw-r--r--Lib/logging/__init__.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 20ab191..276845a 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -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.