mirror of
https://github.com/samschott/maestral.git
synced 2024-09-23 03:47:41 +03:00
[logging] cache formatted log messages
This commit is contained in:
parent
312196fdb8
commit
0eef290e69
@ -55,12 +55,16 @@ class EncodingSafeLogRecord(logging.LogRecord):
|
||||
a :class:`UnicodeEncodeError` under many circumstances (printing to stdout, etc).
|
||||
"""
|
||||
|
||||
_msg: Optional[str] = None
|
||||
|
||||
def getMessage(self) -> str:
|
||||
"""
|
||||
Formats the log message and replaces all surrogate escapes with "<EFBFBD>".
|
||||
"""
|
||||
msg = super().getMessage()
|
||||
return sanitize_string(msg)
|
||||
if not self._msg:
|
||||
self._msg = sanitize_string(super().getMessage())
|
||||
|
||||
return self._msg
|
||||
|
||||
|
||||
logging.setLogRecordFactory(EncodingSafeLogRecord)
|
||||
|
Loading…
Reference in New Issue
Block a user