handle UnicodeDecodeError exceptions when printing log messages
This commit is contained in:
parent
5e17ad88f6
commit
7634be5446
1 changed files with 4 additions and 1 deletions
|
@ -135,7 +135,10 @@ def log(lvl, message, *args, **kwargs):
|
||||||
msg = message.format(*args)
|
msg = message.format(*args)
|
||||||
elif len(kwargs) > 0:
|
elif len(kwargs) > 0:
|
||||||
msg = message.format(**kwargs)
|
msg = message.format(**kwargs)
|
||||||
|
try:
|
||||||
print('[WakaTime] [{lvl}] {msg}'.format(lvl=lvl, msg=msg))
|
print('[WakaTime] [{lvl}] {msg}'.format(lvl=lvl, msg=msg))
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
print(u('[WakaTime] [{lvl}] {msg}').format(lvl=lvl, msg=u(msg)))
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
set_timeout(lambda: log(lvl, message, *args, **kwargs), 0)
|
set_timeout(lambda: log(lvl, message, *args, **kwargs), 0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue