{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/comments/86273709","pull_request_review_id":6938879,"id":86273709,"diff_hunk":"@@ -273,3 +280,40 @@ def list_metrics(self, page_size=None, page_token=None):\n         \"\"\"\n         return self.metrics_api.list_metrics(\n             self.project, page_size, page_token)\n+\n+    def get_default_handler(self):\n+        \"\"\"Return the default logging handler based on the local environment.\n+\n+        :rtype: :class:`logging.Handler`\n+        :returns: The default log handler based on the environment\n+        \"\"\"\n+        if os.getenv('GAE_APPENGINE_HOSTNAME') or os.getenv('GAE_INSTANCE'):\n+            return GAEHandler()\n+        elif os.getenv('KUBERNETES_SERVICE'):\n+            return GKEHandler()\n+        else:\n+            return CloudLoggingHandler(self)\n+\n+    def setup_logging(self, log_level=logging.INFO,\n+                      excluded_loggers=EXCLUDE_LOGGER_DEFAULTS):\n+        \"\"\"Attach default Stackdriver logging handler to the root logger.\n+\n+        This method uses the default log handler, obtained by\n+        :meth:`~get_default_handler`, and attaches it to the root Python\n+        logger, so that a call such as ``logging.warn``, as well as all child\n+        loggers, will report to Stackdriver logging.\n+\n+        :type log_level: :mod:`logging` log level\n+        :param log_level: (Optional) Python logging log level. Defaults to\n+                          :const:`logging.INFO`.\n+\n+        :type excluded_loggers: tuple\n+        :param excluded_loggers: (Optional)nThe loggers to not attach the","path":"logging/google/cloud/logging/client.py","position":53,"original_position":53,"commit_id":"83d23643326858c693cb95b09d1d930a078aa16d","original_commit_id":"83d23643326858c693cb95b09d1d930a078aa16d","user":{"login":"daspecster","id":192456,"avatar_url":"https://avatars.githubusercontent.com/u/192456?v=3","gravatar_id":"","url":"https://api.github.com/users/daspecster","html_url":"https://github.com/daspecster","followers_url":"https://api.github.com/users/daspecster/followers","following_url":"https://api.github.com/users/daspecster/following{/other_user}","gists_url":"https://api.github.com/users/daspecster/gists{/gist_id}","starred_url":"https://api.github.com/users/daspecster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daspecster/subscriptions","organizations_url":"https://api.github.com/users/daspecster/orgs","repos_url":"https://api.github.com/users/daspecster/repos","events_url":"https://api.github.com/users/daspecster/events{/privacy}","received_events_url":"https://api.github.com/users/daspecster/received_events","type":"User","site_admin":false},"body":"```diff\r\n- (Optional)nThe\r\n+ (Optional) The\r\n```","created_at":"2016-11-03T01:03:17Z","updated_at":"2016-11-03T01:13:14Z","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-python/pull/2668#discussion_r86273709","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2668","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/comments/86273709"},"html":{"href":"https://github.com/GoogleCloudPlatform/google-cloud-python/pull/2668#discussion_r86273709"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2668"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2668","id":92080273,"html_url":"https://github.com/GoogleCloudPlatform/google-cloud-python/pull/2668","diff_url":"https://github.com/GoogleCloudPlatform/google-cloud-python/pull/2668.diff","patch_url":"https://github.com/GoogleCloudPlatform/google-cloud-python/pull/2668.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/2668","number":2668,"state":"open","locked":false,"title":"Add GAE and GKE fluentd Handlers","user":{"login":"waprin","id":1075173,"avatar_url":"https://avatars.githubusercontent.com/u/1075173?v=3","gravatar_id":"","url":"https://api.github.com/users/waprin","html_url":"https://github.com/waprin","followers_url":"https://api.github.com/users/waprin/followers","following_url":"https://api.github.com/users/waprin/following{/other_user}","gists_url":"https://api.github.com/users/waprin/gists{/gist_id}","starred_url":"https://api.github.com/users/waprin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waprin/subscriptions","organizations_url":"https://api.github.com/users/waprin/orgs","repos_url":"https://api.github.com/users/waprin/repos","events_url":"https://api.github.com/users/waprin/events{/privacy}","received_events_url":"https://api.github.com/users/waprin/received_events","type":"User","site_admin":false},"body":"On GAE and GKE with the plugin installed, there is a fluentd plugin that collects logs from files. However without the right formatting, metadata like log_level is lost. Furthermore, the fluentd agents are configured to set the  correct resources types, which could be  done in the main handler as well, but it’s easier to rely on the fluentd configurations.\r\n\r\nThis adds two new handlers and some helper functions to detect when they should be used.","created_at":"2016-11-03T00:22:27Z","updated_at":"2016-11-03T01:13:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c5893a71e3728eb96e4afb9d0e4aa14743dec447","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2668/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2668/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/2668/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/statuses/83d23643326858c693cb95b09d1d930a078aa16d","head":{"label":"waprin:newhandlers","ref":"newhandlers","sha":"83d23643326858c693cb95b09d1d930a078aa16d","user":{"login":"waprin","id":1075173,"avatar_url":"https://avatars.githubusercontent.com/u/1075173?v=3","gravatar_id":"","url":"https://api.github.com/users/waprin","html_url":"https://github.com/waprin","followers_url":"https://api.github.com/users/waprin/followers","following_url":"https://api.github.com/users/waprin/following{/other_user}","gists_url":"https://api.github.com/users/waprin/gists{/gist_id}","starred_url":"https://api.github.com/users/waprin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waprin/subscriptions","organizations_url":"https://api.github.com/users/waprin/orgs","repos_url":"https://api.github.com/users/waprin/repos","events_url":"https://api.github.com/users/waprin/events{/privacy}","received_events_url":"https://api.github.com/users/waprin/received_events","type":"User","site_admin":false},"repo":{"id":60732333,"name":"gcloud-python","full_name":"waprin/gcloud-python","owner":{"login":"waprin","id":1075173,"avatar_url":"https://avatars.githubusercontent.com/u/1075173?v=3","gravatar_id":"","url":"https://api.github.com/users/waprin","html_url":"https://github.com/waprin","followers_url":"https://api.github.com/users/waprin/followers","following_url":"https://api.github.com/users/waprin/following{/other_user}","gists_url":"https://api.github.com/users/waprin/gists{/gist_id}","starred_url":"https://api.github.com/users/waprin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waprin/subscriptions","organizations_url":"https://api.github.com/users/waprin/orgs","repos_url":"https://api.github.com/users/waprin/repos","events_url":"https://api.github.com/users/waprin/events{/privacy}","received_events_url":"https://api.github.com/users/waprin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/waprin/gcloud-python","description":"Google Cloud Client Library for Python","fork":true,"url":"https://api.github.com/repos/waprin/gcloud-python","forks_url":"https://api.github.com/repos/waprin/gcloud-python/forks","keys_url":"https://api.github.com/repos/waprin/gcloud-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/waprin/gcloud-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/waprin/gcloud-python/teams","hooks_url":"https://api.github.com/repos/waprin/gcloud-python/hooks","issue_events_url":"https://api.github.com/repos/waprin/gcloud-python/issues/events{/number}","events_url":"https://api.github.com/repos/waprin/gcloud-python/events","assignees_url":"https://api.github.com/repos/waprin/gcloud-python/assignees{/user}","branches_url":"https://api.github.com/repos/waprin/gcloud-python/branches{/branch}","tags_url":"https://api.github.com/repos/waprin/gcloud-python/tags","blobs_url":"https://api.github.com/repos/waprin/gcloud-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/waprin/gcloud-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/waprin/gcloud-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/waprin/gcloud-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/waprin/gcloud-python/statuses/{sha}","languages_url":"https://api.github.com/repos/waprin/gcloud-python/languages","stargazers_url":"https://api.github.com/repos/waprin/gcloud-python/stargazers","contributors_url":"https://api.github.com/repos/waprin/gcloud-python/contributors","subscribers_url":"https://api.github.com/repos/waprin/gcloud-python/subscribers","subscription_url":"https://api.github.com/repos/waprin/gcloud-python/subscription","commits_url":"https://api.github.com/repos/waprin/gcloud-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/waprin/gcloud-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/waprin/gcloud-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/waprin/gcloud-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/waprin/gcloud-python/contents/{+path}","compare_url":"https://api.github.com/repos/waprin/gcloud-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/waprin/gcloud-python/merges","archive_url":"https://api.github.com/repos/waprin/gcloud-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/waprin/gcloud-python/downloads","issues_url":"https://api.github.com/repos/waprin/gcloud-python/issues{/number}","pulls_url":"https://api.github.com/repos/waprin/gcloud-python/pulls{/number}","milestones_url":"https://api.github.com/repos/waprin/gcloud-python/milestones{/number}","notifications_url":"https://api.github.com/repos/waprin/gcloud-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/waprin/gcloud-python/labels{/name}","releases_url":"https://api.github.com/repos/waprin/gcloud-python/releases{/id}","deployments_url":"https://api.github.com/repos/waprin/gcloud-python/deployments","created_at":"2016-06-08T21:34:51Z","updated_at":"2016-06-08T21:34:55Z","pushed_at":"2016-11-03T00:20:10Z","git_url":"git://github.com/waprin/gcloud-python.git","ssh_url":"git@github.com:waprin/gcloud-python.git","clone_url":"https://github.com/waprin/gcloud-python.git","svn_url":"https://github.com/waprin/gcloud-python","homepage":"https://googlecloudplatform.github.io/gcloud-python/","size":57368,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"40d545dea79781452acca9d4cde0e1258a51fce8","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":16316451,"name":"google-cloud-python","full_name":"GoogleCloudPlatform/google-cloud-python","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/google-cloud-python","description":"Google Cloud Client Library for Python","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/deployments","created_at":"2014-01-28T15:51:47Z","updated_at":"2016-11-02T20:28:17Z","pushed_at":"2016-11-03T00:22:28Z","git_url":"git://github.com/GoogleCloudPlatform/google-cloud-python.git","ssh_url":"git@github.com:GoogleCloudPlatform/google-cloud-python.git","clone_url":"https://github.com/GoogleCloudPlatform/google-cloud-python.git","svn_url":"https://github.com/GoogleCloudPlatform/google-cloud-python","homepage":"https://googlecloudplatform.github.io/google-cloud-python/","size":99161,"stargazers_count":442,"watchers_count":442,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":222,"mirror_url":null,"open_issues_count":245,"forks":222,"open_issues":245,"watchers":442,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2668"},"html":{"href":"https://github.com/GoogleCloudPlatform/google-cloud-python/pull/2668"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/2668"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/2668/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2668/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/pulls/2668/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/statuses/83d23643326858c693cb95b09d1d930a078aa16d"}}}}
{"actor":{"display_login":"daspecster"}}