{"action":"created","comment":{"url":"https://api.github.com/repos/heroku/rollrus/pulls/comments/76134214","id":76134214,"diff_hunk":"@@ -80,28 +87,55 @@ func ReportPanic(token, env string) {\n \n // Fire the hook. This is called by Logrus for entries that match the levels\n // returned by Levels(). See below.\n-func (r *Hook) Fire(entry *log.Entry) (err error) {\n-\te := fmt.Errorf(entry.Message)\n+func (r *Hook) Fire(entry *log.Entry) error {\n+\tcause, trace := extractError(entry.Data)\n+\tif cause == nil {\n+\t\tcause = fmt.Errorf(entry.Message)\n+\t}\n+\n \tm := convertFields(entry.Data)\n \tif _, exists := m[\"time\"]; !exists {\n \t\tm[\"time\"] = entry.Time.Format(time.RFC3339)\n \t}\n \n-\tswitch entry.Level {\n-\tcase log.FatalLevel, log.PanicLevel:\n-\t\t_, err = r.Client.Critical(e, m)\n-\tcase log.ErrorLevel:\n-\t\t_, err = r.Client.Error(e, m)\n-\tcase log.WarnLevel:\n-\t\t_, err = r.Client.Warning(e, m)\n-\tcase log.InfoLevel:\n-\t\t_, err = r.Client.Info(entry.Message, m)\n-\tcase log.DebugLevel:\n-\t\t_, err = r.Client.Debug(entry.Message, m)\n-\tdefault:\n-\t\treturn fmt.Errorf(\"Unknown level: %s\", entry.Level)\n-\t}\n+\treturn r.report(entry, cause, m, trace)\n+}\n \n+func (r *Hook) report(entry *log.Entry, cause error, m map[string]string, trace []uintptr) (err error) {","path":"rollrus.go","position":55,"original_position":55,"commit_id":"131d45d438d9aeba607278dc0701908b18a40be2","original_commit_id":"131d45d438d9aeba607278dc0701908b18a40be2","user":{"login":"benburkert","id":77,"avatar_url":"https://avatars.githubusercontent.com/u/77?v=3","gravatar_id":"","url":"https://api.github.com/users/benburkert","html_url":"https://github.com/benburkert","followers_url":"https://api.github.com/users/benburkert/followers","following_url":"https://api.github.com/users/benburkert/following{/other_user}","gists_url":"https://api.github.com/users/benburkert/gists{/gist_id}","starred_url":"https://api.github.com/users/benburkert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benburkert/subscriptions","organizations_url":"https://api.github.com/users/benburkert/orgs","repos_url":"https://api.github.com/users/benburkert/repos","events_url":"https://api.github.com/users/benburkert/events{/privacy}","received_events_url":"https://api.github.com/users/benburkert/received_events","type":"User","site_admin":false},"body":"I think combining it all into a single switch would make this more readable:\r\n\r\n``` go\r\nfunc (r *Hook) report(entry *log.Entry, cause error, m map[string]string, trace []uintptr) (err error) {\r\n\thasTrace := len(trace) > 0\r\n\r\n\tswitch {\r\n\tcase  entry.Level = log.InfoLevel:\r\n\t\t_, err = r.Client.Info(entry.Message, m)\r\n\tcase entry.Level = log.FatalLevel && hasTrace:\r\n\t\t_, err = r.Client.CriticalStack(cause, trace, m)\r\n\tcase entry.Level = log.FatalLevel:\r\n\t\t_, err = r.Client.Critical(cause, trace, m)\r\n\t// ...\r\n\t}\r\n}\r\n```","created_at":"2016-08-24T20:38:15Z","updated_at":"2016-08-24T20:38:15Z","html_url":"https://github.com/heroku/rollrus/pull/6#discussion_r76134214","pull_request_url":"https://api.github.com/repos/heroku/rollrus/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/heroku/rollrus/pulls/comments/76134214"},"html":{"href":"https://github.com/heroku/rollrus/pull/6#discussion_r76134214"},"pull_request":{"href":"https://api.github.com/repos/heroku/rollrus/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/heroku/rollrus/pulls/6","id":82610011,"html_url":"https://github.com/heroku/rollrus/pull/6","diff_url":"https://github.com/heroku/rollrus/pull/6.diff","patch_url":"https://github.com/heroku/rollrus/pull/6.patch","issue_url":"https://api.github.com/repos/heroku/rollrus/issues/6","number":6,"state":"open","locked":false,"title":"Support pkg/error created stack traces","user":{"login":"apg","id":44547,"avatar_url":"https://avatars.githubusercontent.com/u/44547?v=3","gravatar_id":"","url":"https://api.github.com/users/apg","html_url":"https://github.com/apg","followers_url":"https://api.github.com/users/apg/followers","following_url":"https://api.github.com/users/apg/following{/other_user}","gists_url":"https://api.github.com/users/apg/gists{/gist_id}","starred_url":"https://api.github.com/users/apg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apg/subscriptions","organizations_url":"https://api.github.com/users/apg/orgs","repos_url":"https://api.github.com/users/apg/repos","events_url":"https://api.github.com/users/apg/events{/privacy}","received_events_url":"https://api.github.com/users/apg/received_events","type":"User","site_admin":false},"body":"Combines github.com/stvp/roll with github.com/pkg/errors to support sending stack traces generated from `errors.Wrap` and friends to rollbar, instead of rollbar's stack walking.\r\n\r\nThis makes rollrus much more useful since stack traces can represent where the error occurred, not where the log call happened.","created_at":"2016-08-24T20:18:23Z","updated_at":"2016-08-24T20:38:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"af859665a539e2dd4746439cb6a96c466914e1d8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/heroku/rollrus/pulls/6/commits","review_comments_url":"https://api.github.com/repos/heroku/rollrus/pulls/6/comments","review_comment_url":"https://api.github.com/repos/heroku/rollrus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/heroku/rollrus/issues/6/comments","statuses_url":"https://api.github.com/repos/heroku/rollrus/statuses/131d45d438d9aeba607278dc0701908b18a40be2","head":{"label":"heroku:better-stack-trace","ref":"better-stack-trace","sha":"131d45d438d9aeba607278dc0701908b18a40be2","user":{"login":"heroku","id":23211,"avatar_url":"https://avatars.githubusercontent.com/u/23211?v=3","gravatar_id":"","url":"https://api.github.com/users/heroku","html_url":"https://github.com/heroku","followers_url":"https://api.github.com/users/heroku/followers","following_url":"https://api.github.com/users/heroku/following{/other_user}","gists_url":"https://api.github.com/users/heroku/gists{/gist_id}","starred_url":"https://api.github.com/users/heroku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heroku/subscriptions","organizations_url":"https://api.github.com/users/heroku/orgs","repos_url":"https://api.github.com/users/heroku/repos","events_url":"https://api.github.com/users/heroku/events{/privacy}","received_events_url":"https://api.github.com/users/heroku/received_events","type":"Organization","site_admin":false},"repo":{"id":29560980,"name":"rollrus","full_name":"heroku/rollrus","owner":{"login":"heroku","id":23211,"avatar_url":"https://avatars.githubusercontent.com/u/23211?v=3","gravatar_id":"","url":"https://api.github.com/users/heroku","html_url":"https://github.com/heroku","followers_url":"https://api.github.com/users/heroku/followers","following_url":"https://api.github.com/users/heroku/following{/other_user}","gists_url":"https://api.github.com/users/heroku/gists{/gist_id}","starred_url":"https://api.github.com/users/heroku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heroku/subscriptions","organizations_url":"https://api.github.com/users/heroku/orgs","repos_url":"https://api.github.com/users/heroku/repos","events_url":"https://api.github.com/users/heroku/events{/privacy}","received_events_url":"https://api.github.com/users/heroku/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/heroku/rollrus","description":"Logrus Rollbar Hook","fork":false,"url":"https://api.github.com/repos/heroku/rollrus","forks_url":"https://api.github.com/repos/heroku/rollrus/forks","keys_url":"https://api.github.com/repos/heroku/rollrus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heroku/rollrus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heroku/rollrus/teams","hooks_url":"https://api.github.com/repos/heroku/rollrus/hooks","issue_events_url":"https://api.github.com/repos/heroku/rollrus/issues/events{/number}","events_url":"https://api.github.com/repos/heroku/rollrus/events","assignees_url":"https://api.github.com/repos/heroku/rollrus/assignees{/user}","branches_url":"https://api.github.com/repos/heroku/rollrus/branches{/branch}","tags_url":"https://api.github.com/repos/heroku/rollrus/tags","blobs_url":"https://api.github.com/repos/heroku/rollrus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heroku/rollrus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heroku/rollrus/git/refs{/sha}","trees_url":"https://api.github.com/repos/heroku/rollrus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heroku/rollrus/statuses/{sha}","languages_url":"https://api.github.com/repos/heroku/rollrus/languages","stargazers_url":"https://api.github.com/repos/heroku/rollrus/stargazers","contributors_url":"https://api.github.com/repos/heroku/rollrus/contributors","subscribers_url":"https://api.github.com/repos/heroku/rollrus/subscribers","subscription_url":"https://api.github.com/repos/heroku/rollrus/subscription","commits_url":"https://api.github.com/repos/heroku/rollrus/commits{/sha}","git_commits_url":"https://api.github.com/repos/heroku/rollrus/git/commits{/sha}","comments_url":"https://api.github.com/repos/heroku/rollrus/comments{/number}","issue_comment_url":"https://api.github.com/repos/heroku/rollrus/issues/comments{/number}","contents_url":"https://api.github.com/repos/heroku/rollrus/contents/{+path}","compare_url":"https://api.github.com/repos/heroku/rollrus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heroku/rollrus/merges","archive_url":"https://api.github.com/repos/heroku/rollrus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heroku/rollrus/downloads","issues_url":"https://api.github.com/repos/heroku/rollrus/issues{/number}","pulls_url":"https://api.github.com/repos/heroku/rollrus/pulls{/number}","milestones_url":"https://api.github.com/repos/heroku/rollrus/milestones{/number}","notifications_url":"https://api.github.com/repos/heroku/rollrus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heroku/rollrus/labels{/name}","releases_url":"https://api.github.com/repos/heroku/rollrus/releases{/id}","deployments_url":"https://api.github.com/repos/heroku/rollrus/deployments","created_at":"2015-01-20T23:34:26Z","updated_at":"2016-07-19T22:03:55Z","pushed_at":"2016-08-24T20:18:23Z","git_url":"git://github.com/heroku/rollrus.git","ssh_url":"git@github.com:heroku/rollrus.git","clone_url":"https://github.com/heroku/rollrus.git","svn_url":"https://github.com/heroku/rollrus","homepage":null,"size":19,"stargazers_count":5,"watchers_count":5,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":5,"default_branch":"master"}},"base":{"label":"heroku:master","ref":"master","sha":"0a5854aed5595f813e6e2c91f71d7324d5725221","user":{"login":"heroku","id":23211,"avatar_url":"https://avatars.githubusercontent.com/u/23211?v=3","gravatar_id":"","url":"https://api.github.com/users/heroku","html_url":"https://github.com/heroku","followers_url":"https://api.github.com/users/heroku/followers","following_url":"https://api.github.com/users/heroku/following{/other_user}","gists_url":"https://api.github.com/users/heroku/gists{/gist_id}","starred_url":"https://api.github.com/users/heroku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heroku/subscriptions","organizations_url":"https://api.github.com/users/heroku/orgs","repos_url":"https://api.github.com/users/heroku/repos","events_url":"https://api.github.com/users/heroku/events{/privacy}","received_events_url":"https://api.github.com/users/heroku/received_events","type":"Organization","site_admin":false},"repo":{"id":29560980,"name":"rollrus","full_name":"heroku/rollrus","owner":{"login":"heroku","id":23211,"avatar_url":"https://avatars.githubusercontent.com/u/23211?v=3","gravatar_id":"","url":"https://api.github.com/users/heroku","html_url":"https://github.com/heroku","followers_url":"https://api.github.com/users/heroku/followers","following_url":"https://api.github.com/users/heroku/following{/other_user}","gists_url":"https://api.github.com/users/heroku/gists{/gist_id}","starred_url":"https://api.github.com/users/heroku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heroku/subscriptions","organizations_url":"https://api.github.com/users/heroku/orgs","repos_url":"https://api.github.com/users/heroku/repos","events_url":"https://api.github.com/users/heroku/events{/privacy}","received_events_url":"https://api.github.com/users/heroku/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/heroku/rollrus","description":"Logrus Rollbar Hook","fork":false,"url":"https://api.github.com/repos/heroku/rollrus","forks_url":"https://api.github.com/repos/heroku/rollrus/forks","keys_url":"https://api.github.com/repos/heroku/rollrus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heroku/rollrus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heroku/rollrus/teams","hooks_url":"https://api.github.com/repos/heroku/rollrus/hooks","issue_events_url":"https://api.github.com/repos/heroku/rollrus/issues/events{/number}","events_url":"https://api.github.com/repos/heroku/rollrus/events","assignees_url":"https://api.github.com/repos/heroku/rollrus/assignees{/user}","branches_url":"https://api.github.com/repos/heroku/rollrus/branches{/branch}","tags_url":"https://api.github.com/repos/heroku/rollrus/tags","blobs_url":"https://api.github.com/repos/heroku/rollrus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heroku/rollrus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heroku/rollrus/git/refs{/sha}","trees_url":"https://api.github.com/repos/heroku/rollrus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heroku/rollrus/statuses/{sha}","languages_url":"https://api.github.com/repos/heroku/rollrus/languages","stargazers_url":"https://api.github.com/repos/heroku/rollrus/stargazers","contributors_url":"https://api.github.com/repos/heroku/rollrus/contributors","subscribers_url":"https://api.github.com/repos/heroku/rollrus/subscribers","subscription_url":"https://api.github.com/repos/heroku/rollrus/subscription","commits_url":"https://api.github.com/repos/heroku/rollrus/commits{/sha}","git_commits_url":"https://api.github.com/repos/heroku/rollrus/git/commits{/sha}","comments_url":"https://api.github.com/repos/heroku/rollrus/comments{/number}","issue_comment_url":"https://api.github.com/repos/heroku/rollrus/issues/comments{/number}","contents_url":"https://api.github.com/repos/heroku/rollrus/contents/{+path}","compare_url":"https://api.github.com/repos/heroku/rollrus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heroku/rollrus/merges","archive_url":"https://api.github.com/repos/heroku/rollrus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heroku/rollrus/downloads","issues_url":"https://api.github.com/repos/heroku/rollrus/issues{/number}","pulls_url":"https://api.github.com/repos/heroku/rollrus/pulls{/number}","milestones_url":"https://api.github.com/repos/heroku/rollrus/milestones{/number}","notifications_url":"https://api.github.com/repos/heroku/rollrus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heroku/rollrus/labels{/name}","releases_url":"https://api.github.com/repos/heroku/rollrus/releases{/id}","deployments_url":"https://api.github.com/repos/heroku/rollrus/deployments","created_at":"2015-01-20T23:34:26Z","updated_at":"2016-07-19T22:03:55Z","pushed_at":"2016-08-24T20:18:23Z","git_url":"git://github.com/heroku/rollrus.git","ssh_url":"git@github.com:heroku/rollrus.git","clone_url":"https://github.com/heroku/rollrus.git","svn_url":"https://github.com/heroku/rollrus","homepage":null,"size":19,"stargazers_count":5,"watchers_count":5,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/heroku/rollrus/pulls/6"},"html":{"href":"https://github.com/heroku/rollrus/pull/6"},"issue":{"href":"https://api.github.com/repos/heroku/rollrus/issues/6"},"comments":{"href":"https://api.github.com/repos/heroku/rollrus/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/heroku/rollrus/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/heroku/rollrus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/heroku/rollrus/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/heroku/rollrus/statuses/131d45d438d9aeba607278dc0701908b18a40be2"}}}}
{"actor":{"display_login":"benburkert"}}