mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-12 00:44:19 -05:00
Improve comments in the structured logging code. (#10188)
This commit is contained in:
parent
76f9c701c3
commit
18edc9ab06
1
changelog.d/10188.misc
Normal file
1
changelog.d/10188.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Improve comments in structured logging code.
|
@ -20,8 +20,9 @@ import logging
|
|||||||
|
|
||||||
_encoder = json.JSONEncoder(ensure_ascii=False, separators=(",", ":"))
|
_encoder = json.JSONEncoder(ensure_ascii=False, separators=(",", ":"))
|
||||||
|
|
||||||
# The properties of a standard LogRecord.
|
# The properties of a standard LogRecord that should be ignored when generating
|
||||||
_LOG_RECORD_ATTRIBUTES = {
|
# JSON logs.
|
||||||
|
_IGNORED_LOG_RECORD_ATTRIBUTES = {
|
||||||
"args",
|
"args",
|
||||||
"asctime",
|
"asctime",
|
||||||
"created",
|
"created",
|
||||||
@ -59,9 +60,9 @@ class JsonFormatter(logging.Formatter):
|
|||||||
return self._format(record, event)
|
return self._format(record, event)
|
||||||
|
|
||||||
def _format(self, record: logging.LogRecord, event: dict) -> str:
|
def _format(self, record: logging.LogRecord, event: dict) -> str:
|
||||||
# Add any extra attributes to the event.
|
# Add attributes specified via the extra keyword to the logged event.
|
||||||
for key, value in record.__dict__.items():
|
for key, value in record.__dict__.items():
|
||||||
if key not in _LOG_RECORD_ATTRIBUTES:
|
if key not in _IGNORED_LOG_RECORD_ATTRIBUTES:
|
||||||
event[key] = value
|
event[key] = value
|
||||||
|
|
||||||
return _encoder.encode(event)
|
return _encoder.encode(event)
|
||||||
|
Loading…
Reference in New Issue
Block a user