{"action":"created","comment":{"url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/comments/171599536","pull_request_review_id":100480501,"id":171599536,"diff_hunk":"@@ -12,13 +12,17 @@ type config struct {\n \tDBConnectionString string\n \tDBMaxConnections   int\n \tListenAddress      string\n+\tLogLevel           string\n+\tLogFormat          string\n }\n \n func GetConfig() config {\n \treturn config{\n \t\tDBConnectionString: getDBConnectionString(),\n \t\tDBMaxConnections:   getEnvInt(\"DBMAX_CONNECTIONS\", 100),\n \t\tListenAddress:      fmt.Sprintf(\":%v\", getEnvInt(\"PORT\", 3000)),\n+\t\tLogLevel:           strings.ToLower(getEnv(\"LOG_LEVEL\", \"info\")),\n+\t\tLogFormat:          strings.ToLower(getEnv(\"LOG_FORMAT\", \"text\")), //can be text or json","path":"pkg/config/config.go","position":14,"original_position":14,"commit_id":"c09d9ec847efbb6c4b75379912ba975a7c8ac668","original_commit_id":"c09d9ec847efbb6c4b75379912ba975a7c8ac668","user":{"login":"david-martin","id":878251,"avatar_url":"https://avatars1.githubusercontent.com/u/878251?v=4","gravatar_id":"","url":"https://api.github.com/users/david-martin","html_url":"https://github.com/david-martin","followers_url":"https://api.github.com/users/david-martin/followers","following_url":"https://api.github.com/users/david-martin/following{/other_user}","gists_url":"https://api.github.com/users/david-martin/gists{/gist_id}","starred_url":"https://api.github.com/users/david-martin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-martin/subscriptions","organizations_url":"https://api.github.com/users/david-martin/orgs","repos_url":"https://api.github.com/users/david-martin/repos","events_url":"https://api.github.com/users/david-martin/events{/privacy}","received_events_url":"https://api.github.com/users/david-martin/received_events","type":"User","site_admin":false},"body":"Should json be the default?\r\nI'm thinking it would allow easier integration with centralised logging in openshift where you can qeury logs of containers based on json fields\r\n\r\nThoughts @maleck13 @darahayes ","created_at":"2018-03-01T15:44:50Z","updated_at":"2018-03-01T15:44:50Z","html_url":"https://github.com/aerogear/aerogear-app-metrics/pull/32#discussion_r171599536","pull_request_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/32","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/comments/171599536"},"html":{"href":"https://github.com/aerogear/aerogear-app-metrics/pull/32#discussion_r171599536"},"pull_request":{"href":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/32","id":172268378,"html_url":"https://github.com/aerogear/aerogear-app-metrics/pull/32","diff_url":"https://github.com/aerogear/aerogear-app-metrics/pull/32.diff","patch_url":"https://github.com/aerogear/aerogear-app-metrics/pull/32.patch","issue_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/issues/32","number":32,"state":"open","locked":false,"title":"fix: initial logging implementation using logrus","user":{"login":"darahayes","id":8656188,"avatar_url":"https://avatars1.githubusercontent.com/u/8656188?v=4","gravatar_id":"","url":"https://api.github.com/users/darahayes","html_url":"https://github.com/darahayes","followers_url":"https://api.github.com/users/darahayes/followers","following_url":"https://api.github.com/users/darahayes/following{/other_user}","gists_url":"https://api.github.com/users/darahayes/gists{/gist_id}","starred_url":"https://api.github.com/users/darahayes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darahayes/subscriptions","organizations_url":"https://api.github.com/users/darahayes/orgs","repos_url":"https://api.github.com/users/darahayes/repos","events_url":"https://api.github.com/users/darahayes/events{/privacy}","received_events_url":"https://api.github.com/users/darahayes/received_events","type":"User","site_admin":false},"body":"This introduces logging using the popular library [logrus](https://github.com/sirupsen/logrus). Most of the logging is in the MetricsHandler because this is where all the action happens.\r\n\r\nThe logs have 6 different log levels as defined by logrus:\r\n\r\n* Debug\r\n* Info\r\n* Warning\r\n* Error\r\n* Fatal\r\n* Panic\r\n\r\nThe logs can be displayed in two different formats, `text` or `json`.\r\n\r\nexample of a text log:\r\n\r\n```\r\ntime=\"2018-03-01T15:20:57Z\" level=info msg=\"Starting application\" listenAddress=\":3000\"\r\n```\r\n\r\nexample of the same log in json:\r\n\r\n```\r\n{\"level\":\"info\",\"listenAddress\":\":3000\",\"msg\":\"Starting application\",\"time\":\"2018-03-01T15:21:32Z\"}\r\n```\r\n\r\nLog levels and log format can be configured with the following env variables:\r\n\r\n* `LOG_LEVEL`\r\n\t* can be one of [debug, info, warning, error, fatal, panic]\r\n\t* default is `info`\r\n\t* for robustness I've made it case insensitive\r\n* `LOG_FORMAT`\r\n\t* can be one of [json, text]\r\n\t* default is `text` - for readibility during development\r\n\t* case insensitive\r\n\t* Perhaps the `json` option is useful in 'Production' scenarios for log aggregation/analysis technologies like logstash or splunk.\r\n\r\nping @david-martin @maleck13 ","created_at":"2018-03-01T15:27:32Z","updated_at":"2018-03-01T15:44:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c8c0aabc1276610e989335dc9acdaf12321fdc9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/32/commits","review_comments_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/32/comments","review_comment_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/issues/32/comments","statuses_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/statuses/c09d9ec847efbb6c4b75379912ba975a7c8ac668","head":{"label":"aerogear:logging","ref":"logging","sha":"c09d9ec847efbb6c4b75379912ba975a7c8ac668","user":{"login":"aerogear","id":954205,"avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"repo":{"id":121381986,"name":"aerogear-app-metrics","full_name":"aerogear/aerogear-app-metrics","owner":{"login":"aerogear","id":954205,"avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aerogear/aerogear-app-metrics","description":"AeroGear Mobile metrics service","fork":false,"url":"https://api.github.com/repos/aerogear/aerogear-app-metrics","forks_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/forks","keys_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/teams","hooks_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/hooks","issue_events_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/issues/events{/number}","events_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/events","assignees_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/assignees{/user}","branches_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/branches{/branch}","tags_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/tags","blobs_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/languages","stargazers_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/stargazers","contributors_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/contributors","subscribers_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/subscribers","subscription_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/subscription","commits_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/contents/{+path}","compare_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/merges","archive_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/downloads","issues_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/issues{/number}","pulls_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/labels{/name}","releases_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/releases{/id}","deployments_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/deployments","created_at":"2018-02-13T12:50:00Z","updated_at":"2018-02-26T14:50:24Z","pushed_at":"2018-03-01T15:41:54Z","git_url":"git://github.com/aerogear/aerogear-app-metrics.git","ssh_url":"git@github.com:aerogear/aerogear-app-metrics.git","clone_url":"https://github.com/aerogear/aerogear-app-metrics.git","svn_url":"https://github.com/aerogear/aerogear-app-metrics","homepage":null,"size":89,"stargazers_count":2,"watchers_count":2,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":7,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"aerogear:master","ref":"master","sha":"dcc91f842eb120d8a3a82b3c09757ac85dd802e6","user":{"login":"aerogear","id":954205,"avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"repo":{"id":121381986,"name":"aerogear-app-metrics","full_name":"aerogear/aerogear-app-metrics","owner":{"login":"aerogear","id":954205,"avatar_url":"https://avatars1.githubusercontent.com/u/954205?v=4","gravatar_id":"","url":"https://api.github.com/users/aerogear","html_url":"https://github.com/aerogear","followers_url":"https://api.github.com/users/aerogear/followers","following_url":"https://api.github.com/users/aerogear/following{/other_user}","gists_url":"https://api.github.com/users/aerogear/gists{/gist_id}","starred_url":"https://api.github.com/users/aerogear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aerogear/subscriptions","organizations_url":"https://api.github.com/users/aerogear/orgs","repos_url":"https://api.github.com/users/aerogear/repos","events_url":"https://api.github.com/users/aerogear/events{/privacy}","received_events_url":"https://api.github.com/users/aerogear/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aerogear/aerogear-app-metrics","description":"AeroGear Mobile metrics service","fork":false,"url":"https://api.github.com/repos/aerogear/aerogear-app-metrics","forks_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/forks","keys_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/teams","hooks_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/hooks","issue_events_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/issues/events{/number}","events_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/events","assignees_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/assignees{/user}","branches_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/branches{/branch}","tags_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/tags","blobs_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/languages","stargazers_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/stargazers","contributors_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/contributors","subscribers_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/subscribers","subscription_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/subscription","commits_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/contents/{+path}","compare_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/merges","archive_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/downloads","issues_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/issues{/number}","pulls_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/labels{/name}","releases_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/releases{/id}","deployments_url":"https://api.github.com/repos/aerogear/aerogear-app-metrics/deployments","created_at":"2018-02-13T12:50:00Z","updated_at":"2018-02-26T14:50:24Z","pushed_at":"2018-03-01T15:41:54Z","git_url":"git://github.com/aerogear/aerogear-app-metrics.git","ssh_url":"git@github.com:aerogear/aerogear-app-metrics.git","clone_url":"https://github.com/aerogear/aerogear-app-metrics.git","svn_url":"https://github.com/aerogear/aerogear-app-metrics","homepage":null,"size":89,"stargazers_count":2,"watchers_count":2,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":7,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/32"},"html":{"href":"https://github.com/aerogear/aerogear-app-metrics/pull/32"},"issue":{"href":"https://api.github.com/repos/aerogear/aerogear-app-metrics/issues/32"},"comments":{"href":"https://api.github.com/repos/aerogear/aerogear-app-metrics/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aerogear/aerogear-app-metrics/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/aerogear/aerogear-app-metrics/statuses/c09d9ec847efbb6c4b75379912ba975a7c8ac668"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"david-martin"}}