{"action":"closed","issue":{"url":"https://api.github.com/repos/alexcesaro/log/issues/6","labels_url":"https://api.github.com/repos/alexcesaro/log/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/alexcesaro/log/issues/6/comments","events_url":"https://api.github.com/repos/alexcesaro/log/issues/6/events","html_url":"https://github.com/alexcesaro/log/issues/6","id":106476776,"number":6,"title":"proposal: Add log.NullLogger","user":{"login":"shazow","id":6292,"avatar_url":"https://avatars.githubusercontent.com/u/6292?v=3","gravatar_id":"","url":"https://api.github.com/users/shazow","html_url":"https://github.com/shazow","followers_url":"https://api.github.com/users/shazow/followers","following_url":"https://api.github.com/users/shazow/following{/other_user}","gists_url":"https://api.github.com/users/shazow/gists{/gist_id}","starred_url":"https://api.github.com/users/shazow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shazow/subscriptions","organizations_url":"https://api.github.com/users/shazow/orgs","repos_url":"https://api.github.com/users/shazow/repos","events_url":"https://api.github.com/users/shazow/events{/privacy}","received_events_url":"https://api.github.com/users/shazow/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-15T04:38:24Z","updated_at":"2015-09-15T22:13:22Z","closed_at":"2015-09-15T22:13:22Z","body":"I'd like to propose adding a `NullLogger` instance to the `log` package which implements a no-op version of `log.Logger`.\r\n\r\nThis is obviously a minor improvement, but I run into it often enough that I figure it's worth asking. :) I'd be happy to do a PR for this if you'd like.\r\n\r\n## Use case\r\n\r\nIn all of my subpackages, I like to use a package-global log.Logger instance, it typically looks like this:\r\n\r\n```go\r\npackage foo\r\n\r\nimport (\r\n\t\"io/ioutil\"\r\n\r\n\t\"github.com/alexcesaro/log\"\r\n\t\"github.com/alexcesaro/log/golog\"\r\n)\r\n\r\nvar logger log.Logger\r\n\r\nfunc SetLogger(l log.Logger) {\r\n\tlogger = l\r\n}\r\n\r\nfunc init() {\r\n\t// Set a default null logger\r\n\tSetLogger(golog.New(ioutil.Discard, log.None))\r\n}\r\n```\r\n\r\nIdeally, I'd like for this boilerplate file to be more like:\r\n\r\n```go\r\npackage foo\r\n\r\nimport \"github.com/alexcesaro/log\"\r\n\r\nvar logger log.Logger = log.NullLogger\r\n\r\nfunc SetLogger(l log.Logger) {\r\n\tlogger = l\r\n}\r\n```"}}