Skip to content

Commit

Permalink
cli/coloredlogs: apply a fix for logging objects as msg
Browse files Browse the repository at this point in the history
As reported on https://gi
thub.com/xolox/python-coloredlogs/issues/107
logging objects with a __str__ method returning non-ascii characters
raises UnicodeDecodeError.

We have vendored coloredlogs version 0.5 long time ago, so just
apply the suggested fix here for now.
  • Loading branch information
perrinjerome committed Nov 7, 2021
1 parent 80997f7 commit 41c3a1b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion slapos/cli/coloredlogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ def emit(self, record):
message = record.msg
try:
if not isinstance(message, basestring):
message = unicode(message)
try:
message = unicode(message)
except UnicodeDecodeError:
message = unicode(str(message), 'utf-8', 'replace')
except NameError:
if not isinstance(message, str):
message = str(message)
Expand Down

0 comments on commit 41c3a1b

Please sign in to comment.