Resolve merge conflicts

This commit is contained in:
Griatch 2021-10-02 19:20:58 +02:00
commit 8e382d9383
2 changed files with 16 additions and 3 deletions

View file

@ -408,7 +408,16 @@ class EvenniaLogFile(logfile.LogFile):
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("")
return lines
_LOG_FILE_HANDLES = {} # holds open log handles

View file

@ -133,8 +133,12 @@ class ChannelDetailView(ChannelMixin, ObjectDetailView):
for log in (x.strip() for x in tail_log_file(filename, 0, self.max_num_lines)):
if not log:
continue
time, msg = log.split(" [-] ")
time_key = time.split(":")[0]
try:
time, msg = log.split(" [-] ")
time_key = time.split(":")[0]
except ValueError:
# malformed log line. Skip.
continue
bucket.append({"key": time_key, "timestamp": time, "message": msg})