{"action":"created","issue":{"url":"https://api.github.com/repos/pimterry/loglevel/issues/75","labels_url":"https://api.github.com/repos/pimterry/loglevel/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/pimterry/loglevel/issues/75/comments","events_url":"https://api.github.com/repos/pimterry/loglevel/issues/75/events","html_url":"https://github.com/pimterry/loglevel/pull/75","id":91025546,"number":75,"title":"Add a `setDefaultLevel()` method that sets levels only if none were previously persisted.","user":{"login":"Mr0grog","id":74178,"avatar_url":"https://avatars.githubusercontent.com/u/74178?v=3","gravatar_id":"","url":"https://api.github.com/users/Mr0grog","html_url":"https://github.com/Mr0grog","followers_url":"https://api.github.com/users/Mr0grog/followers","following_url":"https://api.github.com/users/Mr0grog/following{/other_user}","gists_url":"https://api.github.com/users/Mr0grog/gists{/gist_id}","starred_url":"https://api.github.com/users/Mr0grog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mr0grog/subscriptions","organizations_url":"https://api.github.com/users/Mr0grog/orgs","repos_url":"https://api.github.com/users/Mr0grog/repos","events_url":"https://api.github.com/users/Mr0grog/events{/privacy}","received_events_url":"https://api.github.com/users/Mr0grog/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-25T17:24:39Z","updated_at":"2015-06-28T14:17:19Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pimterry/loglevel/pulls/75","html_url":"https://github.com/pimterry/loglevel/pull/75","diff_url":"https://github.com/pimterry/loglevel/pull/75.diff","patch_url":"https://github.com/pimterry/loglevel/pull/75.patch"},"body":"I had some time the other day, so I worked up this approach for solving #74. I realize it’s unsolicited, but hopefully it helps to have some working code to look at.\r\n\r\nThe idea is that, if your application automatically sets the logging level on startup, you’d use `setDefaultLevel()` instead of `setLevel()`. That way, if a developer or user opens the console and calls `setLevel()`, that setting will stick on the next page load (instead of being reset by app initialization). For example, your application might set the log level to `error` in a production environment, but when debugging an issue, you might call `setLevel(\"trace\")` on the console to see all the logs. If that `error` setting was set using `setDefaultLevel()`, it will still say as `trace` on subsequent page loads and refreshes instead of resetting to `error`, which would have happened if page scripts used `setLevel()`.\r\n\r\nI’m currently using a slightly more hacky version of this on a web site I’m working on (we check whether anything is stored under “loglevel” in local storage before calling `setLevel()`), but it would be nice to have it built in."},"comment":{"url":"https://api.github.com/repos/pimterry/loglevel/issues/comments/116285940","html_url":"https://github.com/pimterry/loglevel/pull/75#issuecomment-116285940","issue_url":"https://api.github.com/repos/pimterry/loglevel/issues/75","id":116285940,"user":{"login":"pimterry","id":1526883,"avatar_url":"https://avatars.githubusercontent.com/u/1526883?v=3","gravatar_id":"","url":"https://api.github.com/users/pimterry","html_url":"https://github.com/pimterry","followers_url":"https://api.github.com/users/pimterry/followers","following_url":"https://api.github.com/users/pimterry/following{/other_user}","gists_url":"https://api.github.com/users/pimterry/gists{/gist_id}","starred_url":"https://api.github.com/users/pimterry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pimterry/subscriptions","organizations_url":"https://api.github.com/users/pimterry/orgs","repos_url":"https://api.github.com/users/pimterry/repos","events_url":"https://api.github.com/users/pimterry/events{/privacy}","received_events_url":"https://api.github.com/users/pimterry/received_events","type":"User","site_admin":false},"created_at":"2015-06-28T14:17:19Z","updated_at":"2015-06-28T14:17:19Z","body":"Sorry, I've been away for a little while, back now.\r\n\r\nOne small comment added on the code as it stands, but otherwise I'm happy with the feature in general. Thanks for following this up! The one specific thing I am less sure about is the persist argument for the default level. What's the use case for persisting a default level? Could we just make it always non-persistent instead, and keep things simpler?"}}