Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eliot-prettyprint no longer dies on non-JSON lines #249

Merged
merged 8 commits into from
Dec 8, 2015
Merged

Conversation

itamarst
Copy link
Owner

@itamarst itamarst commented Dec 7, 2015

Fixes #219.

try:
message = loads(line)
except ValueError:
stdout.write("(Unparseable JSON, skipping...)\n\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Print these to stderr and include the failed line (or a snippet of)

@wallrj
Copy link
Contributor

wallrj commented Dec 7, 2015

Thanks @itamarst

Looks good, but I think it should also skip non-eliot JSON lines. e.g. those logged by the docker daemon on journald systems.

4b7139d8-1ebc-4a07-a804-63fe0a536fee -> /1
2015-11-30 22:47:03.082205Z
  message_type: 'twisted:log'
  _HOSTNAME: '119.9.108.173'
  _SYSTEMD_UNIT: 'flocker-docker-plugin'
  error: False
  message: 'Stopping factory <twisted.web.client._HTTP11ClientFactory instance at 0x7f1b8da41518>'

Traceback (most recent call last):
  File "/home/richard/.virtualenvs/eliot-245/bin/eliot-prettyprint", line 9, in <module>
    load_entry_point('eliot==0.10.1+11.g61a813a', 'console_scripts', 'eliot-prettyprint')()
  File "/home/richard/projects/HybridLogic/eliot/eliot/prettyprint.py", line 103, in _main
    result = pretty_format(message) + "\n"
  File "/home/richard/projects/HybridLogic/eliot/eliot/prettyprint.py", line 67, in pretty_format
    level = "/" + "/".join(map(unicode, message[TASK_LEVEL_FIELD]))
KeyError: u'task_level'
(eliot-245)(not-json-219 ? =)[~/.../HybridLogic/eliot]$ egrep -A 1 4b7139d8-1ebc-4a07-a804-63fe0a536fee ../flocker/remote_logs.log 
{"_SYSTEMD_UNIT": "flocker-docker-plugin", "timestamp": 1448923623.082205, "task_uuid": "4b7139d8-1ebc-4a07-a804-63fe0a536fee", "_HOSTNAME": "119.9.108.173", "error": false, "message": "Stopping factory <twisted.web.client._HTTP11ClientFactory instance at 0x7f1b8da41518>", "message_type": "twisted:log", "task_level": [1]}
{"_SYSTEMD_UNIT": "docker", "message": "\u001b[34mINFO\u001b[0m[0000] API listen on [::]:2376                      \r", "_HOSTNAME": "119.9.108.173"}
(eliot-245)(not-json-219 ? =)[~/.../HybridLogic/eliot]$ 

Please merge when you've addressed that and added a test for that case.

itamarst added a commit that referenced this pull request Dec 8, 2015
eliot-prettyprint no longer dies on non-JSON lines.

Fixes #219.
@itamarst itamarst merged commit 29b8ab4 into master Dec 8, 2015
@itamarst itamarst deleted the not-json-219 branch December 8, 2015 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants