Skip to content

Commit

Permalink
feat: log print script
Browse files Browse the repository at this point in the history
  • Loading branch information
neurosnap committed Oct 4, 2024
1 parent f30b32f commit 0f8c002
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions scripts/log-print-script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys
import json

def main():
for line in sys.stdin:
try:
parsed = json.loads(line)
msg = parsed["msg"]
user = ""
if "user" in parsed:
user = parsed["user"]
host = ""
if "host" in parsed:
host = parsed["host"]
url = ""
if "url" in parsed:
url = parsed["url"]
status = ""
if "status" in parsed:
status = parsed["status"]
err = ""
if "err" in parsed:
err = parsed["err"]
print(f"{parsed['time']}\t{parsed['level']}\t{user}\t{parsed['service']}\t{msg}\t{err}\t{status}\t{host}\t{url}")
except Exception as err:
print(line)
print("err parsing json", err)

if __name__ == "__main__":
main()

0 comments on commit 0f8c002

Please sign in to comment.