Skip to content

Instantly share code, notes, and snippets.

@kylemanna
Created July 27, 2018 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylemanna/af5d544614411beccfb8df6ef7422126 to your computer and use it in GitHub Desktop.
Save kylemanna/af5d544614411beccfb8df6ef7422126 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
# Process blobs in journalctl logs
#
# journalctl -f -o json | ./journalctl-blob-to-txt.py | jq .
#
import sys
import json
if __name__ == '__main__':
fixed=[]
for line in sys.stdin:
d = json.loads(line)
if type(d['MESSAGE']) == list:
a = [str(unichr(i)) for i in d['MESSAGE']]
d['MESSAGE'] = ''.join(a).strip()
fixed.append(d)
print(json.dumps(fixed))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment