Read about our upcoming Code of Conduct on this issue

Commit 78513401 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Helper script to display JSON logs, especially errors

--HG--
branch : heptapod
parent 4b81a9a31ecd
#!/usr/bin/env python3
import json
from pprint import pprint
def display_one():
try:
raw = input("Please input json message\n")
log = json.loads(raw)
except (EOFError, KeyboardInterrupt):
return False
except json.JSONDecodeError:
print()
print("Not JSON")
return True
if 'exception.class' in log:
print()
print("Exception: ")
print(" class: " + log.pop('exception.class'))
print(" message: " + log.pop('exception.message'))
print(" backtrace: \n " + '\n '.join(log.pop('exception.backtrace', ())))
print()
print("Other fields than exception details: ")
pprint(log)
return True
while display_one():
print()
print()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment