Ensure system log does not raise while processing logger messages (#90652)

This commit is contained in:
J. Nick Koston 2023-04-02 15:18:50 -10:00 committed by GitHub
parent 51ff027fce
commit 73714a6656
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 2 deletions

View file

@ -106,8 +106,11 @@ def _safe_get_message(record: logging.LogRecord) -> str:
"""
try:
return record.getMessage()
except Exception: # pylint: disable=broad-except
return f"Bad logger message: {record.msg} ({record.args})"
except Exception as ex: # pylint: disable=broad-except
try:
return f"Bad logger message: {record.msg} ({record.args})"
except Exception: # pylint: disable=broad-except
return f"Bad logger message: {ex}"
class LogEntry: