Skip to content

Commit

Permalink
fix(dev): parse-controller-logs tool
Browse files Browse the repository at this point in the history
  • Loading branch information
vkrizan committed Dec 4, 2024
1 parent 5b0ff51 commit b0aa1bf
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions parse-controller-logs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b0aa1bf

Please sign in to comment.