diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 9f2c0f0c58a39e..a75bc50a4a27e0 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -1647,7 +1647,7 @@ def __init__(self, logger, extra): adapter = LoggerAdapter(someLogger, dict(p1=v1, p2="v2")) """ self.logger = logger - self.extra = extra + self.extra = extra or {} def process(self, msg, kwargs): """ @@ -1659,7 +1659,7 @@ def process(self, msg, kwargs): Normally, you'll only need to override this one method in a LoggerAdapter subclass for your specific needs. """ - kwargs["extra"] = self.extra + kwargs["extra"] = { **self.extra, **(kwargs.get("extra", {})) } return msg, kwargs # diff --git a/Misc/NEWS.d/next/Library/2018-01-31-19-56-00.bpo-32732.mcOOli.rst b/Misc/NEWS.d/next/Library/2018-01-31-19-56-00.bpo-32732.mcOOli.rst new file mode 100644 index 00000000000000..3b0af3dc6081cd --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-01-31-19-56-00.bpo-32732.mcOOli.rst @@ -0,0 +1 @@ +Do not ignore extra in logging method when a LoggerAdapter is configured. Patch by Cyril Martin