{"action":"created","issue":{"url":"https://api.github.com/repos/lesshint/lesshint/issues/300","repository_url":"https://api.github.com/repos/lesshint/lesshint","labels_url":"https://api.github.com/repos/lesshint/lesshint/issues/300/labels{/name}","comments_url":"https://api.github.com/repos/lesshint/lesshint/issues/300/comments","events_url":"https://api.github.com/repos/lesshint/lesshint/issues/300/events","html_url":"https://github.com/lesshint/lesshint/issues/300","id":196665216,"number":300,"title":"Proposal: pass a logger object to CLI, reporters","user":{"login":"JoshuaKGoldberg","id":3335181,"avatar_url":"https://avatars.githubusercontent.com/u/3335181?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshuaKGoldberg","html_url":"https://github.com/JoshuaKGoldberg","followers_url":"https://api.github.com/users/JoshuaKGoldberg/followers","following_url":"https://api.github.com/users/JoshuaKGoldberg/following{/other_user}","gists_url":"https://api.github.com/users/JoshuaKGoldberg/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshuaKGoldberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshuaKGoldberg/subscriptions","organizations_url":"https://api.github.com/users/JoshuaKGoldberg/orgs","repos_url":"https://api.github.com/users/JoshuaKGoldberg/repos","events_url":"https://api.github.com/users/JoshuaKGoldberg/events{/privacy}","received_events_url":"https://api.github.com/users/JoshuaKGoldberg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-12-20T12:51:23Z","updated_at":"2016-12-20T14:41:36Z","closed_at":null,"body":"Spinning off of #289 - always using the global `console` object to log reports and errors means any constituents of a split-off runner class will have to stub out the standard process outputs.\r\n\r\nInstead of:\r\n\r\n```javascript\r\n    report: function report (results) {\r\n        console.log(JSON.stringify(results));\r\n    }\r\n```\r\n\r\nit could now be:\r\n\r\n```javascript\r\n    report: function report (results, logger) {\r\n        logger.log(JSON.stringify(results));\r\n    }\r\n```\r\n\r\nThe structural changes needed (post Runner-split) would be:\r\n* `bin/lesshint` passes `console` to `lib/cli.js`\r\n* `lib/cli.js` takes in a logger instead of directly using console and passes that to its Runner.\r\n* `lib/runner.js::Runner` takes in a logger and passes it to its reporters.\r\n* reporters are now given a logger object after errors that they can (should) use to log.\r\n\r\nUsing a provided logger gives the benefit that consumers of the reporters (such as our tests or external consumers of lesshint) don't need to globally mock or spy or stub the global console.\r\n\r\nOne downside is that existing custom linters won't be aware of the change, but since it's backwards compatible (doesn't change behavior for existing consumers) I don't think that should be a problem.\r\n\r\n...and I'm of the belief that the term \"dependency injection\" does apply to this despite `console` being a global and not a framework-`new`ed instance :) but that definition does change per person."},"comment":{"url":"https://api.github.com/repos/lesshint/lesshint/issues/comments/268259724","html_url":"https://github.com/lesshint/lesshint/issues/300#issuecomment-268259724","issue_url":"https://api.github.com/repos/lesshint/lesshint/issues/300","id":268259724,"user":{"login":"jwilsson","id":567607,"avatar_url":"https://avatars.githubusercontent.com/u/567607?v=3","gravatar_id":"","url":"https://api.github.com/users/jwilsson","html_url":"https://github.com/jwilsson","followers_url":"https://api.github.com/users/jwilsson/followers","following_url":"https://api.github.com/users/jwilsson/following{/other_user}","gists_url":"https://api.github.com/users/jwilsson/gists{/gist_id}","starred_url":"https://api.github.com/users/jwilsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwilsson/subscriptions","organizations_url":"https://api.github.com/users/jwilsson/orgs","repos_url":"https://api.github.com/users/jwilsson/repos","events_url":"https://api.github.com/users/jwilsson/events{/privacy}","received_events_url":"https://api.github.com/users/jwilsson/received_events","type":"User","site_admin":false},"created_at":"2016-12-20T14:41:36Z","updated_at":"2016-12-20T14:41:36Z","body":"Hmm, if `autolesshint` no longer needs it and we keep all logging in `lib/cli.js` (nothing in `lib/runner.js`) I don't see a need for it as this time.\r\n\r\nIf it's possible to introduce in a backwards compatible way (which it certainly looks like) then we can always add it later."}}
{"actor":{"display_login":"jwilsson"}}