{"action":"created","comment":{"url":"https://api.github.com/repos/prometheus/common/pulls/comments/42719510","id":42719510,"diff_hunk":"@@ -39,10 +41,64 @@ func (f levelFlag) Set(level string) error {\n \treturn nil\n }\n \n+func setSyslogFormatter(appname, facility string) error {\n+\tif appname == \"\" || facility == \"\" {\n+\t\treturn fmt.Errorf(\"your missing a appname(%s) or local(%s)\", appname, facility)\n+\t}\n+\n+\tfmter, err := newSyslogger(appname, facility, origLogger.Formatter)\n+\tif err != nil {\n+\t\tfmt.Fprintf(os.Stderr, \"error creating syslog formatter: %v\\n\", err)\n+\t\torigLogger.Errorf(\"can't connect logger to syslog: %v\", err)\n+\t\treturn err\n+\t}\n+\torigLogger.Formatter = fmter\n+\treturn nil\n+}\n+\n+func setJSONFormatter() {\n+\torigLogger.Formatter = &logrus.JSONFormatter{}\n+}\n+\n+type logFormatFlag struct{ uri string }\n+\n+// String implements flag.Value.\n+func (f logFormatFlag) String() string {\n+\treturn f.uri\n+}\n+\n+// Set implements flag.Value.\n+func (f logFormatFlag) Set(format string) error {\n+\tf.uri = format\n+\tu, err := url.Parse(format)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tif u.Scheme != \"logger\" {\n+\t\treturn fmt.Errorf(\"invalid scheme %s\", u.Scheme)\n+\t}\n+\tjsonq := u.Query().Get(\"json\")\n+\tif jsonq == \"true\" {\n+\t\tsetJSONFormatter()\n+\t}\n+\n+\tswitch u.Opaque {\n+\tcase \"syslog\":\n+\t\tappname := u.Query().Get(\"appname\")\n+\t\tfacility := u.Query().Get(\"local\")\n+\t\treturn setSyslogFormatter(appname, facility)\n+\tcase \"stdout\":","path":"log/log.go","position":59,"original_position":59,"commit_id":"a01ae36e7abf183480addbe283cc57685b5e3f7e","original_commit_id":"b1f2ce56725e33736768fb87c276203ce268c5c6","user":{"login":"mattkanwisher","id":3032,"avatar_url":"https://avatars.githubusercontent.com/u/3032?v=3","gravatar_id":"","url":"https://api.github.com/users/mattkanwisher","html_url":"https://github.com/mattkanwisher","followers_url":"https://api.github.com/users/mattkanwisher/followers","following_url":"https://api.github.com/users/mattkanwisher/following{/other_user}","gists_url":"https://api.github.com/users/mattkanwisher/gists{/gist_id}","starred_url":"https://api.github.com/users/mattkanwisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattkanwisher/subscriptions","organizations_url":"https://api.github.com/users/mattkanwisher/orgs","repos_url":"https://api.github.com/users/mattkanwisher/repos","events_url":"https://api.github.com/users/mattkanwisher/events{/privacy}","received_events_url":"https://api.github.com/users/mattkanwisher/received_events","type":"User","site_admin":false},"body":"nice catch fixed ","created_at":"2015-10-22T07:48:33Z","updated_at":"2015-10-22T07:48:33Z","html_url":"https://github.com/prometheus/common/pull/11#discussion_r42719510","pull_request_url":"https://api.github.com/repos/prometheus/common/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/prometheus/common/pulls/comments/42719510"},"html":{"href":"https://github.com/prometheus/common/pull/11#discussion_r42719510"},"pull_request":{"href":"https://api.github.com/repos/prometheus/common/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/prometheus/common/pulls/11","id":47355781,"html_url":"https://github.com/prometheus/common/pull/11","diff_url":"https://github.com/prometheus/common/pull/11.diff","patch_url":"https://github.com/prometheus/common/pull/11.patch","issue_url":"https://api.github.com/repos/prometheus/common/issues/11","number":11,"state":"open","locked":false,"title":"Add structured logging to json and support for syslog","user":{"login":"mattkanwisher","id":3032,"avatar_url":"https://avatars.githubusercontent.com/u/3032?v=3","gravatar_id":"","url":"https://api.github.com/users/mattkanwisher","html_url":"https://github.com/mattkanwisher","followers_url":"https://api.github.com/users/mattkanwisher/followers","following_url":"https://api.github.com/users/mattkanwisher/following{/other_user}","gists_url":"https://api.github.com/users/mattkanwisher/gists{/gist_id}","starred_url":"https://api.github.com/users/mattkanwisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattkanwisher/subscriptions","organizations_url":"https://api.github.com/users/mattkanwisher/orgs","repos_url":"https://api.github.com/users/mattkanwisher/repos","events_url":"https://api.github.com/users/mattkanwisher/events{/privacy}","received_events_url":"https://api.github.com/users/mattkanwisher/received_events","type":"User","site_admin":false},"body":"We use kibana currently to manage our centralized logging, adding json support will allow native integration with tools like this and logstash. In addition I added syslogger support so people don't need to do manual piping to syslog ","created_at":"2015-10-10T22:47:56Z","updated_at":"2015-10-22T07:48:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bedbd742353495d2b97370e7dcbb17ca91cc4ddc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/prometheus/common/pulls/11/commits","review_comments_url":"https://api.github.com/repos/prometheus/common/pulls/11/comments","review_comment_url":"https://api.github.com/repos/prometheus/common/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prometheus/common/issues/11/comments","statuses_url":"https://api.github.com/repos/prometheus/common/statuses/a01ae36e7abf183480addbe283cc57685b5e3f7e","head":{"label":"mattkanwisher:master","ref":"master","sha":"a01ae36e7abf183480addbe283cc57685b5e3f7e","user":{"login":"mattkanwisher","id":3032,"avatar_url":"https://avatars.githubusercontent.com/u/3032?v=3","gravatar_id":"","url":"https://api.github.com/users/mattkanwisher","html_url":"https://github.com/mattkanwisher","followers_url":"https://api.github.com/users/mattkanwisher/followers","following_url":"https://api.github.com/users/mattkanwisher/following{/other_user}","gists_url":"https://api.github.com/users/mattkanwisher/gists{/gist_id}","starred_url":"https://api.github.com/users/mattkanwisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattkanwisher/subscriptions","organizations_url":"https://api.github.com/users/mattkanwisher/orgs","repos_url":"https://api.github.com/users/mattkanwisher/repos","events_url":"https://api.github.com/users/mattkanwisher/events{/privacy}","received_events_url":"https://api.github.com/users/mattkanwisher/received_events","type":"User","site_admin":false},"repo":{"id":44031135,"name":"common","full_name":"mattkanwisher/common","owner":{"login":"mattkanwisher","id":3032,"avatar_url":"https://avatars.githubusercontent.com/u/3032?v=3","gravatar_id":"","url":"https://api.github.com/users/mattkanwisher","html_url":"https://github.com/mattkanwisher","followers_url":"https://api.github.com/users/mattkanwisher/followers","following_url":"https://api.github.com/users/mattkanwisher/following{/other_user}","gists_url":"https://api.github.com/users/mattkanwisher/gists{/gist_id}","starred_url":"https://api.github.com/users/mattkanwisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattkanwisher/subscriptions","organizations_url":"https://api.github.com/users/mattkanwisher/orgs","repos_url":"https://api.github.com/users/mattkanwisher/repos","events_url":"https://api.github.com/users/mattkanwisher/events{/privacy}","received_events_url":"https://api.github.com/users/mattkanwisher/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mattkanwisher/common","description":"","fork":true,"url":"https://api.github.com/repos/mattkanwisher/common","forks_url":"https://api.github.com/repos/mattkanwisher/common/forks","keys_url":"https://api.github.com/repos/mattkanwisher/common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mattkanwisher/common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mattkanwisher/common/teams","hooks_url":"https://api.github.com/repos/mattkanwisher/common/hooks","issue_events_url":"https://api.github.com/repos/mattkanwisher/common/issues/events{/number}","events_url":"https://api.github.com/repos/mattkanwisher/common/events","assignees_url":"https://api.github.com/repos/mattkanwisher/common/assignees{/user}","branches_url":"https://api.github.com/repos/mattkanwisher/common/branches{/branch}","tags_url":"https://api.github.com/repos/mattkanwisher/common/tags","blobs_url":"https://api.github.com/repos/mattkanwisher/common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mattkanwisher/common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mattkanwisher/common/git/refs{/sha}","trees_url":"https://api.github.com/repos/mattkanwisher/common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mattkanwisher/common/statuses/{sha}","languages_url":"https://api.github.com/repos/mattkanwisher/common/languages","stargazers_url":"https://api.github.com/repos/mattkanwisher/common/stargazers","contributors_url":"https://api.github.com/repos/mattkanwisher/common/contributors","subscribers_url":"https://api.github.com/repos/mattkanwisher/common/subscribers","subscription_url":"https://api.github.com/repos/mattkanwisher/common/subscription","commits_url":"https://api.github.com/repos/mattkanwisher/common/commits{/sha}","git_commits_url":"https://api.github.com/repos/mattkanwisher/common/git/commits{/sha}","comments_url":"https://api.github.com/repos/mattkanwisher/common/comments{/number}","issue_comment_url":"https://api.github.com/repos/mattkanwisher/common/issues/comments{/number}","contents_url":"https://api.github.com/repos/mattkanwisher/common/contents/{+path}","compare_url":"https://api.github.com/repos/mattkanwisher/common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mattkanwisher/common/merges","archive_url":"https://api.github.com/repos/mattkanwisher/common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mattkanwisher/common/downloads","issues_url":"https://api.github.com/repos/mattkanwisher/common/issues{/number}","pulls_url":"https://api.github.com/repos/mattkanwisher/common/pulls{/number}","milestones_url":"https://api.github.com/repos/mattkanwisher/common/milestones{/number}","notifications_url":"https://api.github.com/repos/mattkanwisher/common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mattkanwisher/common/labels{/name}","releases_url":"https://api.github.com/repos/mattkanwisher/common/releases{/id}","created_at":"2015-10-10T22:44:44Z","updated_at":"2015-10-10T22:44:46Z","pushed_at":"2015-10-22T07:48:28Z","git_url":"git://github.com/mattkanwisher/common.git","ssh_url":"git@github.com:mattkanwisher/common.git","clone_url":"https://github.com/mattkanwisher/common.git","svn_url":"https://github.com/mattkanwisher/common","homepage":null,"size":225,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"prometheus:master","ref":"master","sha":"ffe929a3f4c4faeaa10f2b9535c2b1be3ad15650","user":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"repo":{"id":37326770,"name":"common","full_name":"prometheus/common","owner":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prometheus/common","description":"","fork":false,"url":"https://api.github.com/repos/prometheus/common","forks_url":"https://api.github.com/repos/prometheus/common/forks","keys_url":"https://api.github.com/repos/prometheus/common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prometheus/common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prometheus/common/teams","hooks_url":"https://api.github.com/repos/prometheus/common/hooks","issue_events_url":"https://api.github.com/repos/prometheus/common/issues/events{/number}","events_url":"https://api.github.com/repos/prometheus/common/events","assignees_url":"https://api.github.com/repos/prometheus/common/assignees{/user}","branches_url":"https://api.github.com/repos/prometheus/common/branches{/branch}","tags_url":"https://api.github.com/repos/prometheus/common/tags","blobs_url":"https://api.github.com/repos/prometheus/common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prometheus/common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prometheus/common/git/refs{/sha}","trees_url":"https://api.github.com/repos/prometheus/common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prometheus/common/statuses/{sha}","languages_url":"https://api.github.com/repos/prometheus/common/languages","stargazers_url":"https://api.github.com/repos/prometheus/common/stargazers","contributors_url":"https://api.github.com/repos/prometheus/common/contributors","subscribers_url":"https://api.github.com/repos/prometheus/common/subscribers","subscription_url":"https://api.github.com/repos/prometheus/common/subscription","commits_url":"https://api.github.com/repos/prometheus/common/commits{/sha}","git_commits_url":"https://api.github.com/repos/prometheus/common/git/commits{/sha}","comments_url":"https://api.github.com/repos/prometheus/common/comments{/number}","issue_comment_url":"https://api.github.com/repos/prometheus/common/issues/comments{/number}","contents_url":"https://api.github.com/repos/prometheus/common/contents/{+path}","compare_url":"https://api.github.com/repos/prometheus/common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prometheus/common/merges","archive_url":"https://api.github.com/repos/prometheus/common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prometheus/common/downloads","issues_url":"https://api.github.com/repos/prometheus/common/issues{/number}","pulls_url":"https://api.github.com/repos/prometheus/common/pulls{/number}","milestones_url":"https://api.github.com/repos/prometheus/common/milestones{/number}","notifications_url":"https://api.github.com/repos/prometheus/common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prometheus/common/labels{/name}","releases_url":"https://api.github.com/repos/prometheus/common/releases{/id}","created_at":"2015-06-12T14:33:30Z","updated_at":"2015-10-20T05:20:00Z","pushed_at":"2015-10-22T07:48:29Z","git_url":"git://github.com/prometheus/common.git","ssh_url":"git@github.com:prometheus/common.git","clone_url":"https://github.com/prometheus/common.git","svn_url":"https://github.com/prometheus/common","homepage":null,"size":447,"stargazers_count":3,"watchers_count":3,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prometheus/common/pulls/11"},"html":{"href":"https://github.com/prometheus/common/pull/11"},"issue":{"href":"https://api.github.com/repos/prometheus/common/issues/11"},"comments":{"href":"https://api.github.com/repos/prometheus/common/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/prometheus/common/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/prometheus/common/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prometheus/common/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/prometheus/common/statuses/a01ae36e7abf183480addbe283cc57685b5e3f7e"}}}}