summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorƁukasz Langa <lukasz@langa.pl>2017-09-14 15:34:47 (GMT)
committerGitHub <noreply@github.com>2017-09-14 15:34:47 (GMT)
commit1bbd482bcf6ea36bfe488f868810ffe110238ae1 (patch)
tree02fcd023fe78fa0b95287b493d75a0d1c963f48d /Lib/logging
parent5a61559fb0776a9a0f08294ec9003cea13940430 (diff)
downloadcpython-1bbd482bcf6ea36bfe488f868810ffe110238ae1.zip
cpython-1bbd482bcf6ea36bfe488f868810ffe110238ae1.tar.gz
cpython-1bbd482bcf6ea36bfe488f868810ffe110238ae1.tar.bz2
bpo-31457: Allow for nested LoggerAdapter objects (#3551)
Some of the proxied methods use internal Logger state which isn't proxied, causing failures if an adapter is applied to another adapter. This commit fixes the issue, adds a new test for the use case.
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 19b96b8..b941eab 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -1739,6 +1739,27 @@ class LoggerAdapter(object):
"""
return self.logger.hasHandlers()
+ def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False):
+ """
+ Low-level log implementation, proxied to allow nested logger adapters.
+ """
+ return self.logger._log(
+ level,
+ msg,
+ args,
+ exc_info=exc_info,
+ extra=extra,
+ stack_info=stack_info,
+ )
+
+ @property
+ def manager(self):
+ return self.logger.manager
+
+ @manager.setter
+ def set_manager(self, value):
+ self.logger.manager = value
+
def __repr__(self):
logger = self.logger
level = getLevelName(logger.getEffectiveLevel())