From dea97c0991c80aa2e164d26f0534e9b40fe195c4 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 8 Sep 2020 13:54:33 +0100 Subject: [PATCH] Use the right constructor for log records Update `log_function` to use the right factory to create log records, to make sure that they have `request` attributes. Fixes: #8267. --- changelog.d/8278.bugfix | 1 + synapse/logging/utils.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelog.d/8278.bugfix diff --git a/changelog.d/8278.bugfix b/changelog.d/8278.bugfix new file mode 100644 index 000000000000..50e40ca2a9da --- /dev/null +++ b/changelog.d/8278.bugfix @@ -0,0 +1 @@ +Fix a bug which cause the logging system to report errors, if `DEBUG` was enabled and no `context` filter was applied. diff --git a/synapse/logging/utils.py b/synapse/logging/utils.py index fea774e2e524..becf66dd86c8 100644 --- a/synapse/logging/utils.py +++ b/synapse/logging/utils.py @@ -29,11 +29,11 @@ def _log_debug_as_f(f, msg, msg_args): lineno = f.__code__.co_firstlineno pathname = f.__code__.co_filename - record = logging.LogRecord( + record = logger.makeRecord( name=name, level=logging.DEBUG, - pathname=pathname, - lineno=lineno, + fn=pathname, + lno=lineno, msg=msg, args=msg_args, exc_info=None,