Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
18edc9ab
Unverified
Commit
18edc9ab
authored
3 years ago
by
Patrick Cloke
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Improve comments in the structured logging code. (#10188)
parent
76f9c701
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/10188.misc
+1
-0
1 addition, 0 deletions
changelog.d/10188.misc
synapse/logging/_terse_json.py
+5
-4
5 additions, 4 deletions
synapse/logging/_terse_json.py
with
6 additions
and
4 deletions
changelog.d/10188.misc
0 → 100644
+
1
−
0
View file @
18edc9ab
Improve comments in structured logging code.
This diff is collapsed.
Click to expand it.
synapse/logging/_terse_json.py
+
5
−
4
View file @
18edc9ab
...
@@ -20,8 +20,9 @@ import logging
...
@@ -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):
...
@@ -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 a
ny extra attributes to the
event.
# Add a
ttributes 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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment