Skip to content

Commit fabf85e

Browse files
committed
Restore LoggingContextFilter.__init__ constructor
See: - #18868 (comment) - #18868 (comment)
1 parent 09b9756 commit fabf85e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

synapse/logging/context.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,28 @@ class LoggingContextFilter(logging.Filter):
587587
record.
588588
"""
589589

590+
def __init__(
591+
self,
592+
# `request` is here for backwards compatibility since we previously recommended
593+
# people manually configure `LoggingContextFilter` like the following.
594+
#
595+
# ```yaml
596+
# filters:
597+
# context:
598+
# (): synapse.logging.context.LoggingContextFilter
599+
# request: ""
600+
# ```
601+
#
602+
# TODO: Since we now configure `LoggingContextFilter` automatically since #8051
603+
# (2020-08-11), we could consider removing this useless parameter. This would
604+
# require people to remove their own manual configuration of
605+
# `LoggingContextFilter` as it would cause `TypeError: Filter.__init__() got an
606+
# unexpected keyword argument 'request'` -> `ValueError: Unable to configure
607+
# filter 'context'`
608+
request: str = "",
609+
):
610+
self._default_request = request
611+
590612
def filter(self, record: logging.LogRecord) -> Literal[True]:
591613
"""Add each fields from the logging contexts to the record.
592614
Returns:

0 commit comments

Comments
 (0)