Skip to content

Instantly share code, notes, and snippets.

@udoprog
Last active February 7, 2017 16:42
Show Gist options
  • Select an option

  • Save udoprog/b4603a1842b35c3a0a7ebc3bfc130ab7 to your computer and use it in GitHub Desktop.

Select an option

Save udoprog/b4603a1842b35c3a0a7ebc3bfc130ab7 to your computer and use it in GitHub Desktop.
import datetime
import sys
import json
def printThrown(thrown):
if 'message' in thrown:
print " {name}: {message}".format(**thrown)
else:
print " {name}".format(**thrown)
if 'extendedStackTrace' in thrown:
for entry in thrown['extendedStackTrace']:
print " at {class}.{method}({file}:{line})".format(**entry)
if 'cause' in thrown:
print " caused by:"
printThrown(thrown['cause'])
for line in sys.stdin:
doc = json.loads(line)
ms = doc['timeMillis']
timestamp = datetime.datetime.fromtimestamp(ms/1000.0)
print timestamp.isoformat() + ": " + doc['message']
if 'thrown' in doc:
thrown = doc['thrown']
printThrown(doc['thrown'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment