Catch unicode-decode error in logger display
This commit is contained in:
parent
36ded8408d
commit
c041425bca
1 changed files with 9 additions and 1 deletions
|
|
@ -392,7 +392,15 @@ class EvenniaLogFile(logfile.LogFile):
|
||||||
Returns:
|
Returns:
|
||||||
lines (list): lines from our _file attribute.
|
lines (list): lines from our _file attribute.
|
||||||
"""
|
"""
|
||||||
return [line.decode("utf-8") for line in self._file.readlines(*args, **kwargs)]
|
lines = []
|
||||||
|
for line in self._file.readlines(*args, **kwargs):
|
||||||
|
try:
|
||||||
|
lines.append(line.decode("utf-8"))
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
try:
|
||||||
|
lines.append(str(line))
|
||||||
|
except Exception:
|
||||||
|
lines.append("")
|
||||||
|
|
||||||
|
|
||||||
_LOG_FILE_HANDLES = {} # holds open log handles
|
_LOG_FILE_HANDLES = {} # holds open log handles
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue