diff --git a/parse-controller-logs b/parse-controller-logs index f167db96a..569b9dca2 100755 --- a/parse-controller-logs +++ b/parse-controller-logs @@ -22,28 +22,28 @@ def col_wrap(stri, collev): filters = {sp[0]: sp[1] for sp in [arg.split(":", 1) for arg in sys.argv[1:]]} def print_message(line): - ts = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(js["ts"]))) + ts = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(line["ts"]))) string = "" - if 'level' in js: - collev = levels[js['level']] - elif js.get('diff') != None: + if 'level' in line: + collev = levels.get(line['level'], levels["info"]) + elif line.get('diff') != None: collev = levels['diff'] else: collev = cancel_colour string += collev - app = "[%s]" % js["app"] if "app" in js else "" - env = "[%s]" % js["env"] if "env" in js else "" + app = "[%s]" % line["app"] if "app" in line else "" + env = "[%s]" % line["env"] if "env" in line else "" - string += f'[{ts}] {js["level"].upper()} {js.get("ctrl", "").upper()} {app or env} {js["msg"]} ' + string += f'[{ts}] {line["level"].upper()} {line.get("ctrl", "").upper()} {app or env} {line["msg"]} ' rms = ["msg", "ts", "level", "ctrl", "logger"] for key in rms: - if key in js: - del(js[key]) - s_key = sorted(js.keys()) - string += " ".join([f"{col_wrap(k, collev)}:{js[k]}" for k in s_key]) + if key in line: + del(line[key]) + s_key = sorted(line.keys()) + string += " ".join([f"{col_wrap(f"{k}:", collev)}{line[k]}" for k in s_key]) string += cancel_colour print(string)