{"action":"created","comment":{"url":"https://api.github.com/repos/Sagacify/logger-py/pulls/comments/86953427","pull_request_review_id":7583921,"id":86953427,"diff_hunk":"@@ -1,199 +1,96 @@\n \"\"\"\n-Bunyan Formatter.\n+SagaFormatter\n \n-Provides logging compatibility with Bunyan standard and enceforth CLI.\n+Ensures logs are formatted as we want them.\n+cfr: https://github.com/sagacify/logger\n \"\"\"\n import datetime\n-import json\n-import logging\n-import socket\n-import traceback\n import os\n+import socket\n import sys\n+import time\n+import json\n \n-from inspect import istraceback\n-\n-# Support order in python 2.7 and 3\n-try:\n-    from collections import OrderedDict\n-except ImportError:\n-    pass\n-\n-\n-def object_startswith(key, value):\n-    return hasattr(key, 'startswith') and key.startswith(value)\n \n+def extra_serializer(obj):\n+    if isinstance(obj, datetime.datetime):\n+        return obj.isoformat() + 'Z'\n+    elif isinstance(obj, datetime.date):\n+        return obj.isoformat()\n+    elif isinstance(obj, datetime.time):\n+        return obj.strftime('%H:%M')\n+    else:\n+        raise TypeError(type(obj))\n \n-def merge_record_extra(record, target, reserved=[]):\n-    \"\"\"\n-    Merges extra attributes from LogRecord object into target dictionary.\n \n-    :param record: logging.LogRecord\n-    :param target: dict to update\n-    :param reserved: dict or list with reserved keys to skip\n-    \"\"\"\n-    new_values = {\n-        key: value\n-        for key, value in record.__dict__.items()\n-        if (key not in reserved and not object_startswith(key, '_'))\n-    }\n+def get_name_from_args():\n+    return (sys.argv[0] or sys.executable).split(os.sep)[-1]\n \n-    target.update(new_values)\n \n-    return target\n+def get_app_name_version():\n+    main_module = sys.modules['__main__']\n \n+    # If importing from jupyter hub or cli.\n+    if main_module.__package__ is None:\n+        return get_name_from_args(), sys.version.split(' ')[0]\n \n-def get_json_handler(datefmt):\n-    def handler(obj):\n-        '''Prints dates in ISO format'''\n-        if isinstance(obj, datetime.datetime):\n-            if obj.year < 1900:\n-                # strftime do not work with date < 1900\n-                return obj.isoformat()\n+    app_package = sys.modules[main_module.__package__]\n+    try:\n+        app_name = app_package.__title__\n+        app_version = app_package.__version__\n+    except AttributeError:\n+        print('FATAL: could not access package info.')\n+        sys.exit(-1)\n+    return app_name, app_version\n \n-            return obj.strftime(datefmt or '%Y-%m-%dT%H:%M')\n-        elif isinstance(obj, datetime.date):\n-            return obj.isoformat()\n-        elif isinstance(obj, datetime.time):\n-            return obj.strftime('%H:%M')\n-        elif istraceback(obj):\n-            tb = ''.join(traceback.format_tb(obj))\n \n-            return tb.strip()\n-        elif isinstance(obj, Exception):\n-            return 'Exception: %s' % str(obj)\n+def format_time(record):\n+    \"\"\"Format time to ISO 8601.\n \n-        return str(obj)\n-\n-    return handler\n+    https://en.wikipedia.org/wiki/ISO_8601\n+    \"\"\"\n+    utc_time = time.gmtime(record.created)\n+    time_string = time.strftime('%Y-%m-%d %H:%M:%S', utc_time)\n+    return '%s.%03dZ' % (time_string, record.msecs)\n \n \n-class SagaFormatter(logging.Formatter):\n+class SagaFormatter(object):","path":"src/formatter.py","position":109,"original_position":109,"commit_id":"bd29331b4ddba58e64ab30d305acd688eecb2c78","original_commit_id":"bd29331b4ddba58e64ab30d305acd688eecb2c78","user":{"login":"satblip","id":1811109,"avatar_url":"https://avatars.githubusercontent.com/u/1811109?v=3","gravatar_id":"","url":"https://api.github.com/users/satblip","html_url":"https://github.com/satblip","followers_url":"https://api.github.com/users/satblip/followers","following_url":"https://api.github.com/users/satblip/following{/other_user}","gists_url":"https://api.github.com/users/satblip/gists{/gist_id}","starred_url":"https://api.github.com/users/satblip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/satblip/subscriptions","organizations_url":"https://api.github.com/users/satblip/orgs","repos_url":"https://api.github.com/users/satblip/repos","events_url":"https://api.github.com/users/satblip/events{/privacy}","received_events_url":"https://api.github.com/users/satblip/received_events","type":"User","site_admin":false},"body":"tu vas laisser un warning sonar, je ne te reconnais plus... :p","created_at":"2016-11-08T09:41:04Z","updated_at":"2016-11-08T09:41:04Z","html_url":"https://github.com/Sagacify/logger-py/pull/6#discussion_r86953427","pull_request_url":"https://api.github.com/repos/Sagacify/logger-py/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/Sagacify/logger-py/pulls/comments/86953427"},"html":{"href":"https://github.com/Sagacify/logger-py/pull/6#discussion_r86953427"},"pull_request":{"href":"https://api.github.com/repos/Sagacify/logger-py/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/Sagacify/logger-py/pulls/6","id":92451964,"html_url":"https://github.com/Sagacify/logger-py/pull/6","diff_url":"https://github.com/Sagacify/logger-py/pull/6.diff","patch_url":"https://github.com/Sagacify/logger-py/pull/6.patch","issue_url":"https://api.github.com/repos/Sagacify/logger-py/issues/6","number":6,"state":"open","locked":false,"title":"Fix","user":{"login":"aborsu","id":5033617,"avatar_url":"https://avatars.githubusercontent.com/u/5033617?v=3","gravatar_id":"","url":"https://api.github.com/users/aborsu","html_url":"https://github.com/aborsu","followers_url":"https://api.github.com/users/aborsu/followers","following_url":"https://api.github.com/users/aborsu/following{/other_user}","gists_url":"https://api.github.com/users/aborsu/gists{/gist_id}","starred_url":"https://api.github.com/users/aborsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aborsu/subscriptions","organizations_url":"https://api.github.com/users/aborsu/orgs","repos_url":"https://api.github.com/users/aborsu/repos","events_url":"https://api.github.com/users/aborsu/events{/privacy}","received_events_url":"https://api.github.com/users/aborsu/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-05T12:29:17Z","updated_at":"2016-11-08T09:41:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5367646378740a81b604da2af1d696afe2ff157d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Sagacify/logger-py/pulls/6/commits","review_comments_url":"https://api.github.com/repos/Sagacify/logger-py/pulls/6/comments","review_comment_url":"https://api.github.com/repos/Sagacify/logger-py/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sagacify/logger-py/issues/6/comments","statuses_url":"https://api.github.com/repos/Sagacify/logger-py/statuses/bd29331b4ddba58e64ab30d305acd688eecb2c78","head":{"label":"Sagacify:fix","ref":"fix","sha":"bd29331b4ddba58e64ab30d305acd688eecb2c78","user":{"login":"Sagacify","id":1648230,"avatar_url":"https://avatars.githubusercontent.com/u/1648230?v=3","gravatar_id":"","url":"https://api.github.com/users/Sagacify","html_url":"https://github.com/Sagacify","followers_url":"https://api.github.com/users/Sagacify/followers","following_url":"https://api.github.com/users/Sagacify/following{/other_user}","gists_url":"https://api.github.com/users/Sagacify/gists{/gist_id}","starred_url":"https://api.github.com/users/Sagacify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sagacify/subscriptions","organizations_url":"https://api.github.com/users/Sagacify/orgs","repos_url":"https://api.github.com/users/Sagacify/repos","events_url":"https://api.github.com/users/Sagacify/events{/privacy}","received_events_url":"https://api.github.com/users/Sagacify/received_events","type":"Organization","site_admin":false},"repo":{"id":61360009,"name":"logger-py","full_name":"Sagacify/logger-py","owner":{"login":"Sagacify","id":1648230,"avatar_url":"https://avatars.githubusercontent.com/u/1648230?v=3","gravatar_id":"","url":"https://api.github.com/users/Sagacify","html_url":"https://github.com/Sagacify","followers_url":"https://api.github.com/users/Sagacify/followers","following_url":"https://api.github.com/users/Sagacify/following{/other_user}","gists_url":"https://api.github.com/users/Sagacify/gists{/gist_id}","starred_url":"https://api.github.com/users/Sagacify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sagacify/subscriptions","organizations_url":"https://api.github.com/users/Sagacify/orgs","repos_url":"https://api.github.com/users/Sagacify/repos","events_url":"https://api.github.com/users/Sagacify/events{/privacy}","received_events_url":"https://api.github.com/users/Sagacify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sagacify/logger-py","description":"Bunyan like logger for python","fork":false,"url":"https://api.github.com/repos/Sagacify/logger-py","forks_url":"https://api.github.com/repos/Sagacify/logger-py/forks","keys_url":"https://api.github.com/repos/Sagacify/logger-py/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sagacify/logger-py/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sagacify/logger-py/teams","hooks_url":"https://api.github.com/repos/Sagacify/logger-py/hooks","issue_events_url":"https://api.github.com/repos/Sagacify/logger-py/issues/events{/number}","events_url":"https://api.github.com/repos/Sagacify/logger-py/events","assignees_url":"https://api.github.com/repos/Sagacify/logger-py/assignees{/user}","branches_url":"https://api.github.com/repos/Sagacify/logger-py/branches{/branch}","tags_url":"https://api.github.com/repos/Sagacify/logger-py/tags","blobs_url":"https://api.github.com/repos/Sagacify/logger-py/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sagacify/logger-py/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sagacify/logger-py/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sagacify/logger-py/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sagacify/logger-py/statuses/{sha}","languages_url":"https://api.github.com/repos/Sagacify/logger-py/languages","stargazers_url":"https://api.github.com/repos/Sagacify/logger-py/stargazers","contributors_url":"https://api.github.com/repos/Sagacify/logger-py/contributors","subscribers_url":"https://api.github.com/repos/Sagacify/logger-py/subscribers","subscription_url":"https://api.github.com/repos/Sagacify/logger-py/subscription","commits_url":"https://api.github.com/repos/Sagacify/logger-py/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sagacify/logger-py/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sagacify/logger-py/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sagacify/logger-py/issues/comments{/number}","contents_url":"https://api.github.com/repos/Sagacify/logger-py/contents/{+path}","compare_url":"https://api.github.com/repos/Sagacify/logger-py/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sagacify/logger-py/merges","archive_url":"https://api.github.com/repos/Sagacify/logger-py/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sagacify/logger-py/downloads","issues_url":"https://api.github.com/repos/Sagacify/logger-py/issues{/number}","pulls_url":"https://api.github.com/repos/Sagacify/logger-py/pulls{/number}","milestones_url":"https://api.github.com/repos/Sagacify/logger-py/milestones{/number}","notifications_url":"https://api.github.com/repos/Sagacify/logger-py/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sagacify/logger-py/labels{/name}","releases_url":"https://api.github.com/repos/Sagacify/logger-py/releases{/id}","deployments_url":"https://api.github.com/repos/Sagacify/logger-py/deployments","created_at":"2016-06-17T08:54:13Z","updated_at":"2016-10-15T14:35:24Z","pushed_at":"2016-11-07T22:44:11Z","git_url":"git://github.com/Sagacify/logger-py.git","ssh_url":"git@github.com:Sagacify/logger-py.git","clone_url":"https://github.com/Sagacify/logger-py.git","svn_url":"https://github.com/Sagacify/logger-py","homepage":null,"size":34,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"Sagacify:master","ref":"master","sha":"1fd6e12d4e5b4bd514a2af10db9017e050f21236","user":{"login":"Sagacify","id":1648230,"avatar_url":"https://avatars.githubusercontent.com/u/1648230?v=3","gravatar_id":"","url":"https://api.github.com/users/Sagacify","html_url":"https://github.com/Sagacify","followers_url":"https://api.github.com/users/Sagacify/followers","following_url":"https://api.github.com/users/Sagacify/following{/other_user}","gists_url":"https://api.github.com/users/Sagacify/gists{/gist_id}","starred_url":"https://api.github.com/users/Sagacify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sagacify/subscriptions","organizations_url":"https://api.github.com/users/Sagacify/orgs","repos_url":"https://api.github.com/users/Sagacify/repos","events_url":"https://api.github.com/users/Sagacify/events{/privacy}","received_events_url":"https://api.github.com/users/Sagacify/received_events","type":"Organization","site_admin":false},"repo":{"id":61360009,"name":"logger-py","full_name":"Sagacify/logger-py","owner":{"login":"Sagacify","id":1648230,"avatar_url":"https://avatars.githubusercontent.com/u/1648230?v=3","gravatar_id":"","url":"https://api.github.com/users/Sagacify","html_url":"https://github.com/Sagacify","followers_url":"https://api.github.com/users/Sagacify/followers","following_url":"https://api.github.com/users/Sagacify/following{/other_user}","gists_url":"https://api.github.com/users/Sagacify/gists{/gist_id}","starred_url":"https://api.github.com/users/Sagacify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sagacify/subscriptions","organizations_url":"https://api.github.com/users/Sagacify/orgs","repos_url":"https://api.github.com/users/Sagacify/repos","events_url":"https://api.github.com/users/Sagacify/events{/privacy}","received_events_url":"https://api.github.com/users/Sagacify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sagacify/logger-py","description":"Bunyan like logger for python","fork":false,"url":"https://api.github.com/repos/Sagacify/logger-py","forks_url":"https://api.github.com/repos/Sagacify/logger-py/forks","keys_url":"https://api.github.com/repos/Sagacify/logger-py/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sagacify/logger-py/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sagacify/logger-py/teams","hooks_url":"https://api.github.com/repos/Sagacify/logger-py/hooks","issue_events_url":"https://api.github.com/repos/Sagacify/logger-py/issues/events{/number}","events_url":"https://api.github.com/repos/Sagacify/logger-py/events","assignees_url":"https://api.github.com/repos/Sagacify/logger-py/assignees{/user}","branches_url":"https://api.github.com/repos/Sagacify/logger-py/branches{/branch}","tags_url":"https://api.github.com/repos/Sagacify/logger-py/tags","blobs_url":"https://api.github.com/repos/Sagacify/logger-py/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sagacify/logger-py/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sagacify/logger-py/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sagacify/logger-py/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sagacify/logger-py/statuses/{sha}","languages_url":"https://api.github.com/repos/Sagacify/logger-py/languages","stargazers_url":"https://api.github.com/repos/Sagacify/logger-py/stargazers","contributors_url":"https://api.github.com/repos/Sagacify/logger-py/contributors","subscribers_url":"https://api.github.com/repos/Sagacify/logger-py/subscribers","subscription_url":"https://api.github.com/repos/Sagacify/logger-py/subscription","commits_url":"https://api.github.com/repos/Sagacify/logger-py/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sagacify/logger-py/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sagacify/logger-py/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sagacify/logger-py/issues/comments{/number}","contents_url":"https://api.github.com/repos/Sagacify/logger-py/contents/{+path}","compare_url":"https://api.github.com/repos/Sagacify/logger-py/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sagacify/logger-py/merges","archive_url":"https://api.github.com/repos/Sagacify/logger-py/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sagacify/logger-py/downloads","issues_url":"https://api.github.com/repos/Sagacify/logger-py/issues{/number}","pulls_url":"https://api.github.com/repos/Sagacify/logger-py/pulls{/number}","milestones_url":"https://api.github.com/repos/Sagacify/logger-py/milestones{/number}","notifications_url":"https://api.github.com/repos/Sagacify/logger-py/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sagacify/logger-py/labels{/name}","releases_url":"https://api.github.com/repos/Sagacify/logger-py/releases{/id}","deployments_url":"https://api.github.com/repos/Sagacify/logger-py/deployments","created_at":"2016-06-17T08:54:13Z","updated_at":"2016-10-15T14:35:24Z","pushed_at":"2016-11-07T22:44:11Z","git_url":"git://github.com/Sagacify/logger-py.git","ssh_url":"git@github.com:Sagacify/logger-py.git","clone_url":"https://github.com/Sagacify/logger-py.git","svn_url":"https://github.com/Sagacify/logger-py","homepage":null,"size":34,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sagacify/logger-py/pulls/6"},"html":{"href":"https://github.com/Sagacify/logger-py/pull/6"},"issue":{"href":"https://api.github.com/repos/Sagacify/logger-py/issues/6"},"comments":{"href":"https://api.github.com/repos/Sagacify/logger-py/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/Sagacify/logger-py/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/Sagacify/logger-py/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sagacify/logger-py/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/Sagacify/logger-py/statuses/bd29331b4ddba58e64ab30d305acd688eecb2c78"}}}}
{"actor":{"display_login":"satblip"}}