Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 18edc9a

Browse files
authored
Improve comments in the structured logging code. (#10188)
1 parent 76f9c70 commit 18edc9a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

changelog.d/10188.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve comments in structured logging code.

synapse/logging/_terse_json.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020

2121
_encoder = json.JSONEncoder(ensure_ascii=False, separators=(",", ":"))
2222

23-
# The properties of a standard LogRecord.
24-
_LOG_RECORD_ATTRIBUTES = {
23+
# The properties of a standard LogRecord that should be ignored when generating
24+
# JSON logs.
25+
_IGNORED_LOG_RECORD_ATTRIBUTES = {
2526
"args",
2627
"asctime",
2728
"created",
@@ -59,9 +60,9 @@ def format(self, record: logging.LogRecord) -> str:
5960
return self._format(record, event)
6061

6162
def _format(self, record: logging.LogRecord, event: dict) -> str:
62-
# Add any extra attributes to the event.
63+
# Add attributes specified via the extra keyword to the logged event.
6364
for key, value in record.__dict__.items():
64-
if key not in _LOG_RECORD_ATTRIBUTES:
65+
if key not in _IGNORED_LOG_RECORD_ATTRIBUTES:
6566
event[key] = value
6667

6768
return _encoder.encode(event)

0 commit comments

Comments
 (0)