Fix display issues on release API endpoint

pull/1311/head^2
LASER-Yi 4 years ago
parent 2d0e3af693
commit 26850929a8

@ -515,17 +515,20 @@ class SystemLogs(Resource):
def get(self): def get(self):
logs = [] logs = []
with io.open(os.path.join(args.config_dir, 'log', 'bazarr.log'), encoding='UTF-8') as file: with io.open(os.path.join(args.config_dir, 'log', 'bazarr.log'), encoding='UTF-8') as file:
for line in file.readlines(): raw_lines = file.read()
lin = line.split('|') lines = raw_lines.split('|\n')
if len(lin) > 4: for line in lines:
raw_message = line.split('|')
raw_message_len = len(raw_message)
if raw_message_len > 3:
log = dict() log = dict()
log["timestamp"] = lin[0] log["timestamp"] = raw_message[0]
log["type"] = lin[1].rstrip() log["type"] = raw_message[1].rstrip()
log["message"] = lin[3] log["message"] = raw_message[3]
if lin[4] != '\n': if raw_message_len > 4 and raw_message[4] != '\n':
log['exception'] = lin[4].strip('\'').replace(' ', '\u2003\u2003') log['exception'] = raw_message[4].strip('\'').replace(' ', '\u2003\u2003')
logs.append(log) logs.append(log)
logs.reverse() logs.reverse()
return jsonify(data=logs) return jsonify(data=logs)

Loading…
Cancel
Save