Skip to content

Commit

Permalink
More robust logging (#1171)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchop authored Nov 14, 2024
1 parent 6f01784 commit 91ac456
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def emit(self, record):

if "body" in record.__dict__ and record.__dict__["body"]:
try:
content = json.loads(record.__dict__["body"].decode("utf-8"))
content = record.__dict__["body"]
if isinstance(content, bytes):
content = content.decode("utf-8")
content = json.loads(content)
except (UnicodeDecodeError, json.JSONDecodeError):
# We don't want to log binary or non-JSON content.
content = {}
Expand Down

0 comments on commit 91ac456

Please sign in to comment.