{"action":"opened","number":95,"pull_request":{"url":"https://api.github.com/repos/essenciary/Genie.jl/pulls/95","id":241467449,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQxNDY3NDQ5","html_url":"https://github.com/essenciary/Genie.jl/pull/95","diff_url":"https://github.com/essenciary/Genie.jl/pull/95.diff","patch_url":"https://github.com/essenciary/Genie.jl/pull/95.patch","issue_url":"https://api.github.com/repos/essenciary/Genie.jl/issues/95","number":95,"state":"open","locked":false,"title":"Logging PoC","user":{"login":"GearsAD","id":6854507,"node_id":"MDQ6VXNlcjY4NTQ1MDc=","avatar_url":"https://avatars2.githubusercontent.com/u/6854507?v=4","gravatar_id":"","url":"https://api.github.com/users/GearsAD","html_url":"https://github.com/GearsAD","followers_url":"https://api.github.com/users/GearsAD/followers","following_url":"https://api.github.com/users/GearsAD/following{/other_user}","gists_url":"https://api.github.com/users/GearsAD/gists{/gist_id}","starred_url":"https://api.github.com/users/GearsAD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GearsAD/subscriptions","organizations_url":"https://api.github.com/users/GearsAD/orgs","repos_url":"https://api.github.com/users/GearsAD/repos","events_url":"https://api.github.com/users/GearsAD/events{/privacy}","received_events_url":"https://api.github.com/users/GearsAD/received_events","type":"User","site_admin":false},"body":"Hi @essenciary,\r\n\r\nNot quite ready to merge this, but this is a PoC to use Julia's logging capabilities for Genie. \r\n* Created a default ConsoleLogger, and specfied a formatter that allows you to change the prefix and suffix of a log message. Just added the timestamp to it for now, you could change to whatever is best.\r\n* Put in an initialize_logging function that is called from AppServer.jl as it starts. This function configures the ConsoleLogger and sets it as the global logger\r\n* I wanted to keep the existing log() function signature, so I just translated between the log symbols/strings to Julia's LogLevel enumeration\r\n* I've tested this against a large number of calls and it seems to be stable\r\n* Updated to remove Memento and Millboard (not sure Milboard that was being used elsewhere? Can reintroduce)\r\n\r\nTwo things that are not yet addressed:\r\n* I only log to console and pipe the console data to a file in my use-case, so I didn't look at how the file configuration is done. However, the ConsoleLogger class allows you to pass a stream to it, so that could  be redirected to a file.\r\n* I didn't look at message truncation (I see you have an option for that). We would have to do some work to make that fit because ConsoleLogger only truncates to display size - [ConsoleLogger Display Size](https://github.com/JuliaLang/julia/blob/099e826241fca365a120df9bac9a9fede6e7bae4/stdlib/Logging/src/ConsoleLogger.jl#L109-L115). If that's important, a bit of refactoring would be needed.\r\n\r\nThoughts? If this is heading in the right direction, we can work on refining it.\r\n\r\nBelow included the 3 test cases I was using.\r\n\r\n(I've made a small change to Router.jl to check if route handlers return nothing as part of the 3rd test case.)\r\n\r\n### Test Server:\r\n```julia\r\nusing Genie.Router, Genie.Loggers\r\n\r\n# Case 1: Info logging\r\nroute(\"/\") do\r\n  log(\"Hello!\", :info)\r\n  @info \"Hello!\" #Should be same\r\n  return \"HELO!\"\r\nend\r\n# Case 2: Exception logging - bubbling up an exception - should log and send to user\r\nroute(\"/bubbleexception\") do\r\n  error(\"Bubble up to logging and as response\")\r\nend\r\n# Case 3: Trap exception inside route handler, log it, and continue.\r\nroute(\"/trapexception\") do\r\n  try\r\n    error(\"Ruh roh something broke\")\r\n  catch ex\r\n    log(ex, :error)\r\n  end\r\n  # Returning nothing, so this call is the one where I included a small check for nothing in Router.jl:736 \r\nend\r\n```\r\n\r\n### Case 1 - Informational logging:\r\n```\r\n[ [2018-12-29T16:37:57.242] Info: Accept (1):  🔗    0↑     0↓    0s 0.0.0.0:8000:8000 ≣16\r\n[ [2018-12-29T16:38:02.796] Info: Hello!\r\n[ [2018-12-29T16:38:02.796] Info: Hello!\r\n┌ [2018-12-29T16:38:02.873] Info: [2018-12-29T16:38:02.822] -- :/ -- Done\r\n\r\n```\r\n### Case 2 - Bubbling up an exception:\r\n```\r\n┌ [2018-12-29T16:32:07.561] Error: Distributed.RemoteException(1, CapturedException(ErrorException(\"Bubble up to logging and as response\"), Any[(error(::String) at error.jl:33, 1), ((::##5#6)() at routes.jl:11, 1), (#invokelatest#1 at essentials.jl:697 [inlined], 1), \r\n...\r\n```\r\n\r\n### Case 3 - Trapping+logging an exception:\r\n```\r\n┌ [2018-12-29T16:30:53.216] Error: ErrorException(\"Ruh roh something broke\")\r\n└ @ Genie.Loggers ~/.julia/dev/Genie/src/Loggers.jl:96\r\n┌ [2018-12-29T16:30:53.229] Error: Can't convert nothing to HttpServer.Response\r\n└ @ Genie.Loggers ~/.julia/dev/Genie/src/Loggers.jl:96\r\n┌ [2018-12-29T16:30:53.232] Error: ErrorException(\"Route handler returned nothing. Please ensure a valid action result is returned.\")\r\n```\r\n","created_at":"2018-12-29T22:50:40Z","updated_at":"2018-12-29T22:50:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/essenciary/Genie.jl/pulls/95/commits","review_comments_url":"https://api.github.com/repos/essenciary/Genie.jl/pulls/95/comments","review_comment_url":"https://api.github.com/repos/essenciary/Genie.jl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/essenciary/Genie.jl/issues/95/comments","statuses_url":"https://api.github.com/repos/essenciary/Genie.jl/statuses/13b1d5c0cc399084ba1a6e01b1f246d2d645bdeb","head":{"label":"GearsAD:master","ref":"master","sha":"13b1d5c0cc399084ba1a6e01b1f246d2d645bdeb","user":{"login":"GearsAD","id":6854507,"node_id":"MDQ6VXNlcjY4NTQ1MDc=","avatar_url":"https://avatars2.githubusercontent.com/u/6854507?v=4","gravatar_id":"","url":"https://api.github.com/users/GearsAD","html_url":"https://github.com/GearsAD","followers_url":"https://api.github.com/users/GearsAD/followers","following_url":"https://api.github.com/users/GearsAD/following{/other_user}","gists_url":"https://api.github.com/users/GearsAD/gists{/gist_id}","starred_url":"https://api.github.com/users/GearsAD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GearsAD/subscriptions","organizations_url":"https://api.github.com/users/GearsAD/orgs","repos_url":"https://api.github.com/users/GearsAD/repos","events_url":"https://api.github.com/users/GearsAD/events{/privacy}","received_events_url":"https://api.github.com/users/GearsAD/received_events","type":"User","site_admin":false},"repo":{"id":159284494,"node_id":"MDEwOlJlcG9zaXRvcnkxNTkyODQ0OTQ=","name":"Genie.jl","full_name":"GearsAD/Genie.jl","private":false,"owner":{"login":"GearsAD","id":6854507,"node_id":"MDQ6VXNlcjY4NTQ1MDc=","avatar_url":"https://avatars2.githubusercontent.com/u/6854507?v=4","gravatar_id":"","url":"https://api.github.com/users/GearsAD","html_url":"https://github.com/GearsAD","followers_url":"https://api.github.com/users/GearsAD/followers","following_url":"https://api.github.com/users/GearsAD/following{/other_user}","gists_url":"https://api.github.com/users/GearsAD/gists{/gist_id}","starred_url":"https://api.github.com/users/GearsAD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GearsAD/subscriptions","organizations_url":"https://api.github.com/users/GearsAD/orgs","repos_url":"https://api.github.com/users/GearsAD/repos","events_url":"https://api.github.com/users/GearsAD/events{/privacy}","received_events_url":"https://api.github.com/users/GearsAD/received_events","type":"User","site_admin":false},"html_url":"https://github.com/GearsAD/Genie.jl","description":"The highly productive Julia web framework","fork":true,"url":"https://api.github.com/repos/GearsAD/Genie.jl","forks_url":"https://api.github.com/repos/GearsAD/Genie.jl/forks","keys_url":"https://api.github.com/repos/GearsAD/Genie.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GearsAD/Genie.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GearsAD/Genie.jl/teams","hooks_url":"https://api.github.com/repos/GearsAD/Genie.jl/hooks","issue_events_url":"https://api.github.com/repos/GearsAD/Genie.jl/issues/events{/number}","events_url":"https://api.github.com/repos/GearsAD/Genie.jl/events","assignees_url":"https://api.github.com/repos/GearsAD/Genie.jl/assignees{/user}","branches_url":"https://api.github.com/repos/GearsAD/Genie.jl/branches{/branch}","tags_url":"https://api.github.com/repos/GearsAD/Genie.jl/tags","blobs_url":"https://api.github.com/repos/GearsAD/Genie.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GearsAD/Genie.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GearsAD/Genie.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/GearsAD/Genie.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GearsAD/Genie.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/GearsAD/Genie.jl/languages","stargazers_url":"https://api.github.com/repos/GearsAD/Genie.jl/stargazers","contributors_url":"https://api.github.com/repos/GearsAD/Genie.jl/contributors","subscribers_url":"https://api.github.com/repos/GearsAD/Genie.jl/subscribers","subscription_url":"https://api.github.com/repos/GearsAD/Genie.jl/subscription","commits_url":"https://api.github.com/repos/GearsAD/Genie.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/GearsAD/Genie.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/GearsAD/Genie.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/GearsAD/Genie.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/GearsAD/Genie.jl/contents/{+path}","compare_url":"https://api.github.com/repos/GearsAD/Genie.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GearsAD/Genie.jl/merges","archive_url":"https://api.github.com/repos/GearsAD/Genie.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GearsAD/Genie.jl/downloads","issues_url":"https://api.github.com/repos/GearsAD/Genie.jl/issues{/number}","pulls_url":"https://api.github.com/repos/GearsAD/Genie.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/GearsAD/Genie.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/GearsAD/Genie.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GearsAD/Genie.jl/labels{/name}","releases_url":"https://api.github.com/repos/GearsAD/Genie.jl/releases{/id}","deployments_url":"https://api.github.com/repos/GearsAD/Genie.jl/deployments","created_at":"2018-11-27T06:05:31Z","updated_at":"2018-12-29T22:39:54Z","pushed_at":"2018-12-29T22:39:52Z","git_url":"git://github.com/GearsAD/Genie.jl.git","ssh_url":"git@github.com:GearsAD/Genie.jl.git","clone_url":"https://github.com/GearsAD/Genie.jl.git","svn_url":"https://github.com/GearsAD/Genie.jl","homepage":"http://genieframework.com","size":19902,"stargazers_count":0,"watchers_count":0,"language":"Julia","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"essenciary:master","ref":"master","sha":"1c441ae220d6979b04c32e3a0a962b51839798cf","user":{"login":"essenciary","id":11292378,"node_id":"MDQ6VXNlcjExMjkyMzc4","avatar_url":"https://avatars0.githubusercontent.com/u/11292378?v=4","gravatar_id":"","url":"https://api.github.com/users/essenciary","html_url":"https://github.com/essenciary","followers_url":"https://api.github.com/users/essenciary/followers","following_url":"https://api.github.com/users/essenciary/following{/other_user}","gists_url":"https://api.github.com/users/essenciary/gists{/gist_id}","starred_url":"https://api.github.com/users/essenciary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/essenciary/subscriptions","organizations_url":"https://api.github.com/users/essenciary/orgs","repos_url":"https://api.github.com/users/essenciary/repos","events_url":"https://api.github.com/users/essenciary/events{/privacy}","received_events_url":"https://api.github.com/users/essenciary/received_events","type":"User","site_admin":false},"repo":{"id":52076467,"node_id":"MDEwOlJlcG9zaXRvcnk1MjA3NjQ2Nw==","name":"Genie.jl","full_name":"essenciary/Genie.jl","private":false,"owner":{"login":"essenciary","id":11292378,"node_id":"MDQ6VXNlcjExMjkyMzc4","avatar_url":"https://avatars0.githubusercontent.com/u/11292378?v=4","gravatar_id":"","url":"https://api.github.com/users/essenciary","html_url":"https://github.com/essenciary","followers_url":"https://api.github.com/users/essenciary/followers","following_url":"https://api.github.com/users/essenciary/following{/other_user}","gists_url":"https://api.github.com/users/essenciary/gists{/gist_id}","starred_url":"https://api.github.com/users/essenciary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/essenciary/subscriptions","organizations_url":"https://api.github.com/users/essenciary/orgs","repos_url":"https://api.github.com/users/essenciary/repos","events_url":"https://api.github.com/users/essenciary/events{/privacy}","received_events_url":"https://api.github.com/users/essenciary/received_events","type":"User","site_admin":false},"html_url":"https://github.com/essenciary/Genie.jl","description":"The highly productive Julia web framework","fork":false,"url":"https://api.github.com/repos/essenciary/Genie.jl","forks_url":"https://api.github.com/repos/essenciary/Genie.jl/forks","keys_url":"https://api.github.com/repos/essenciary/Genie.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/essenciary/Genie.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/essenciary/Genie.jl/teams","hooks_url":"https://api.github.com/repos/essenciary/Genie.jl/hooks","issue_events_url":"https://api.github.com/repos/essenciary/Genie.jl/issues/events{/number}","events_url":"https://api.github.com/repos/essenciary/Genie.jl/events","assignees_url":"https://api.github.com/repos/essenciary/Genie.jl/assignees{/user}","branches_url":"https://api.github.com/repos/essenciary/Genie.jl/branches{/branch}","tags_url":"https://api.github.com/repos/essenciary/Genie.jl/tags","blobs_url":"https://api.github.com/repos/essenciary/Genie.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/essenciary/Genie.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/essenciary/Genie.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/essenciary/Genie.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/essenciary/Genie.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/essenciary/Genie.jl/languages","stargazers_url":"https://api.github.com/repos/essenciary/Genie.jl/stargazers","contributors_url":"https://api.github.com/repos/essenciary/Genie.jl/contributors","subscribers_url":"https://api.github.com/repos/essenciary/Genie.jl/subscribers","subscription_url":"https://api.github.com/repos/essenciary/Genie.jl/subscription","commits_url":"https://api.github.com/repos/essenciary/Genie.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/essenciary/Genie.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/essenciary/Genie.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/essenciary/Genie.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/essenciary/Genie.jl/contents/{+path}","compare_url":"https://api.github.com/repos/essenciary/Genie.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/essenciary/Genie.jl/merges","archive_url":"https://api.github.com/repos/essenciary/Genie.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/essenciary/Genie.jl/downloads","issues_url":"https://api.github.com/repos/essenciary/Genie.jl/issues{/number}","pulls_url":"https://api.github.com/repos/essenciary/Genie.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/essenciary/Genie.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/essenciary/Genie.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/essenciary/Genie.jl/labels{/name}","releases_url":"https://api.github.com/repos/essenciary/Genie.jl/releases{/id}","deployments_url":"https://api.github.com/repos/essenciary/Genie.jl/deployments","created_at":"2016-02-19T09:23:20Z","updated_at":"2018-12-29T18:25:33Z","pushed_at":"2018-12-29T19:26:23Z","git_url":"git://github.com/essenciary/Genie.jl.git","ssh_url":"git@github.com:essenciary/Genie.jl.git","clone_url":"https://github.com/essenciary/Genie.jl.git","svn_url":"https://github.com/essenciary/Genie.jl","homepage":"http://genieframework.com","size":19893,"stargazers_count":414,"watchers_count":414,"language":"Julia","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"archived":false,"open_issues_count":22,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":32,"open_issues":22,"watchers":414,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/essenciary/Genie.jl/pulls/95"},"html":{"href":"https://github.com/essenciary/Genie.jl/pull/95"},"issue":{"href":"https://api.github.com/repos/essenciary/Genie.jl/issues/95"},"comments":{"href":"https://api.github.com/repos/essenciary/Genie.jl/issues/95/comments"},"review_comments":{"href":"https://api.github.com/repos/essenciary/Genie.jl/pulls/95/comments"},"review_comment":{"href":"https://api.github.com/repos/essenciary/Genie.jl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/essenciary/Genie.jl/pulls/95/commits"},"statuses":{"href":"https://api.github.com/repos/essenciary/Genie.jl/statuses/13b1d5c0cc399084ba1a6e01b1f246d2d645bdeb"}},"author_association":"CONTRIBUTOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":4,"additions":77,"deletions":27,"changed_files":4}}
{"actor":{"display_login":"GearsAD"}}