{"action":"created","comment":{"url":"https://api.github.com/repos/ClusterHQ/eliot/pulls/comments/40468699","id":40468699,"diff_hunk":"@@ -0,0 +1,73 @@\n+\"\"\"\n+API and command-line support for human-readable Eliot messages.\n+\"\"\"\n+\n+from __future__ import unicode_literals\n+\n+from datetime import datetime\n+from sys import stdin, stdout, argv\n+from json import loads\n+\n+from six import text_type as unicode, PY2\n+\n+\n+def pretty_print(message):\n+    \"\"\"\n+    Convert a message dictionary into a human-readable string.\n+\n+    @param message: Message to parse, as dictionary.\n+\n+    @return: Unicode string.\n+    \"\"\"\n+    skip = {\"timestamp\", \"task_uuid\", \"task_level\", \"action_counter\",\n+            \"message_type\", \"action_type\", \"action_status\"}\n+\n+    def add_field(previous, key, value):\n+        value = unicode(value).rstrip(\"\\n\")\n+        # Reindent second line and later to match up with first line's\n+        # indentation:\n+        lines = value.split(\"\\n\")\n+        indent = \" \" * (2 + len(key) + 2)  # lines are \"  <key>: <value>\"\n+        value = \"\\n\".join([lines[0]] + [indent + l for l in lines[1:]])\n+        return \"  %s: %s\\n\" % (key, value)\n+\n+    remaining = \"\"\n+    for field in [\"action_type\", \"message_type\", \"action_status\"]:\n+        if field in message:\n+            remaining += add_field(remaining, field, message[field])\n+    for (key, value) in sorted(message.items()):\n+        if key not in skip:\n+            remaining += add_field(remaining, key, value)\n+\n+    level = \"/\" + \"/\".join(map(unicode, message[\"task_level\"]))\n+    return \"%s@%s\\n%sZ\\n%s\" % (\n+        message[\"task_uuid\"],\n+        level,\n+        datetime.utcfromtimestamp(message[\"timestamp\"]).isoformat(),","path":"eliot/prettyprint.py","position":46,"original_position":46,"commit_id":"37b72bce425f8470d7d9b61dd5948bf5e33395c2","original_commit_id":"37b72bce425f8470d7d9b61dd5948bf5e33395c2","user":{"login":"exarkun","id":254565,"avatar_url":"https://avatars.githubusercontent.com/u/254565?v=3","gravatar_id":"","url":"https://api.github.com/users/exarkun","html_url":"https://github.com/exarkun","followers_url":"https://api.github.com/users/exarkun/followers","following_url":"https://api.github.com/users/exarkun/following{/other_user}","gists_url":"https://api.github.com/users/exarkun/gists{/gist_id}","starred_url":"https://api.github.com/users/exarkun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exarkun/subscriptions","organizations_url":"https://api.github.com/users/exarkun/orgs","repos_url":"https://api.github.com/users/exarkun/repos","events_url":"https://api.github.com/users/exarkun/events{/privacy}","received_events_url":"https://api.github.com/users/exarkun/received_events","type":"User","site_admin":false},"body":"I suggest `isoformat(sep=\" \")`","created_at":"2015-09-25T19:48:15Z","updated_at":"2015-09-25T19:48:15Z","html_url":"https://github.com/ClusterHQ/eliot/pull/209#discussion_r40468699","pull_request_url":"https://api.github.com/repos/ClusterHQ/eliot/pulls/209","_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/eliot/pulls/comments/40468699"},"html":{"href":"https://github.com/ClusterHQ/eliot/pull/209#discussion_r40468699"},"pull_request":{"href":"https://api.github.com/repos/ClusterHQ/eliot/pulls/209"}}},"pull_request":{"url":"https://api.github.com/repos/ClusterHQ/eliot/pulls/209","id":46050521,"html_url":"https://github.com/ClusterHQ/eliot/pull/209","diff_url":"https://github.com/ClusterHQ/eliot/pull/209.diff","patch_url":"https://github.com/ClusterHQ/eliot/pull/209.patch","issue_url":"https://api.github.com/repos/ClusterHQ/eliot/issues/209","number":209,"state":"open","locked":false,"title":"Command-line utility to make messages easier to read","user":{"login":"itamarst","id":3266662,"avatar_url":"https://avatars.githubusercontent.com/u/3266662?v=3","gravatar_id":"","url":"https://api.github.com/users/itamarst","html_url":"https://github.com/itamarst","followers_url":"https://api.github.com/users/itamarst/followers","following_url":"https://api.github.com/users/itamarst/following{/other_user}","gists_url":"https://api.github.com/users/itamarst/gists{/gist_id}","starred_url":"https://api.github.com/users/itamarst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itamarst/subscriptions","organizations_url":"https://api.github.com/users/itamarst/orgs","repos_url":"https://api.github.com/users/itamarst/repos","events_url":"https://api.github.com/users/itamarst/events{/privacy}","received_events_url":"https://api.github.com/users/itamarst/received_events","type":"User","site_admin":false},"body":"Fixes #208.","created_at":"2015-09-25T19:46:27Z","updated_at":"2015-09-25T19:48:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c9c6e5db03f3befeb8eee816e64f0abd74db58e5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ClusterHQ/eliot/pulls/209/commits","review_comments_url":"https://api.github.com/repos/ClusterHQ/eliot/pulls/209/comments","review_comment_url":"https://api.github.com/repos/ClusterHQ/eliot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ClusterHQ/eliot/issues/209/comments","statuses_url":"https://api.github.com/repos/ClusterHQ/eliot/statuses/37b72bce425f8470d7d9b61dd5948bf5e33395c2","head":{"label":"ClusterHQ:prettyprint-208","ref":"prettyprint-208","sha":"37b72bce425f8470d7d9b61dd5948bf5e33395c2","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":18601900,"name":"eliot","full_name":"ClusterHQ/eliot","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/eliot","description":"Eliot: a causality-based logging library for Python","fork":false,"url":"https://api.github.com/repos/ClusterHQ/eliot","forks_url":"https://api.github.com/repos/ClusterHQ/eliot/forks","keys_url":"https://api.github.com/repos/ClusterHQ/eliot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/eliot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/eliot/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/eliot/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/eliot/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/eliot/events","assignees_url":"https://api.github.com/repos/ClusterHQ/eliot/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/eliot/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/eliot/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/eliot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/eliot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/eliot/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/eliot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/eliot/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/eliot/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/eliot/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/eliot/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/eliot/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/eliot/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/eliot/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/eliot/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/eliot/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/eliot/issues/comments{/number}","contents_url":"https://api.github.com/repos/ClusterHQ/eliot/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/eliot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/eliot/merges","archive_url":"https://api.github.com/repos/ClusterHQ/eliot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/eliot/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/eliot/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/eliot/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/eliot/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/eliot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/eliot/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/eliot/releases{/id}","created_at":"2014-04-09T15:12:19Z","updated_at":"2015-09-17T01:06:52Z","pushed_at":"2015-09-25T19:46:28Z","git_url":"git://github.com/ClusterHQ/eliot.git","ssh_url":"git@github.com:ClusterHQ/eliot.git","clone_url":"https://github.com/ClusterHQ/eliot.git","svn_url":"https://github.com/ClusterHQ/eliot","homepage":"http://pypi.python.org/pypi/eliot","size":1449,"stargazers_count":122,"watchers_count":122,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":81,"forks":12,"open_issues":81,"watchers":122,"default_branch":"master"}},"base":{"label":"ClusterHQ:master","ref":"master","sha":"87bcc5347dd621e76698f97ec6fa95cd3c634e6b","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":18601900,"name":"eliot","full_name":"ClusterHQ/eliot","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/eliot","description":"Eliot: a causality-based logging library for Python","fork":false,"url":"https://api.github.com/repos/ClusterHQ/eliot","forks_url":"https://api.github.com/repos/ClusterHQ/eliot/forks","keys_url":"https://api.github.com/repos/ClusterHQ/eliot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/eliot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/eliot/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/eliot/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/eliot/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/eliot/events","assignees_url":"https://api.github.com/repos/ClusterHQ/eliot/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/eliot/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/eliot/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/eliot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/eliot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/eliot/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/eliot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/eliot/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/eliot/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/eliot/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/eliot/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/eliot/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/eliot/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/eliot/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/eliot/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/eliot/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/eliot/issues/comments{/number}","contents_url":"https://api.github.com/repos/ClusterHQ/eliot/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/eliot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/eliot/merges","archive_url":"https://api.github.com/repos/ClusterHQ/eliot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/eliot/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/eliot/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/eliot/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/eliot/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/eliot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/eliot/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/eliot/releases{/id}","created_at":"2014-04-09T15:12:19Z","updated_at":"2015-09-17T01:06:52Z","pushed_at":"2015-09-25T19:46:28Z","git_url":"git://github.com/ClusterHQ/eliot.git","ssh_url":"git@github.com:ClusterHQ/eliot.git","clone_url":"https://github.com/ClusterHQ/eliot.git","svn_url":"https://github.com/ClusterHQ/eliot","homepage":"http://pypi.python.org/pypi/eliot","size":1449,"stargazers_count":122,"watchers_count":122,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":81,"forks":12,"open_issues":81,"watchers":122,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/eliot/pulls/209"},"html":{"href":"https://github.com/ClusterHQ/eliot/pull/209"},"issue":{"href":"https://api.github.com/repos/ClusterHQ/eliot/issues/209"},"comments":{"href":"https://api.github.com/repos/ClusterHQ/eliot/issues/209/comments"},"review_comments":{"href":"https://api.github.com/repos/ClusterHQ/eliot/pulls/209/comments"},"review_comment":{"href":"https://api.github.com/repos/ClusterHQ/eliot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ClusterHQ/eliot/pulls/209/commits"},"statuses":{"href":"https://api.github.com/repos/ClusterHQ/eliot/statuses/37b72bce425f8470d7d9b61dd5948bf5e33395c2"}}}}