{"action":"created","issue":{"url":"https://api.github.com/repos/go-kit/kit/issues/164","labels_url":"https://api.github.com/repos/go-kit/kit/issues/164/labels{/name}","comments_url":"https://api.github.com/repos/go-kit/kit/issues/164/comments","events_url":"https://api.github.com/repos/go-kit/kit/issues/164/events","html_url":"https://github.com/go-kit/kit/issues/164","id":121109249,"number":164,"title":"Explain why Logger.log() returns error","user":{"login":"cep21","id":20358,"avatar_url":"https://avatars.githubusercontent.com/u/20358?v=3","gravatar_id":"","url":"https://api.github.com/users/cep21","html_url":"https://github.com/cep21","followers_url":"https://api.github.com/users/cep21/followers","following_url":"https://api.github.com/users/cep21/following{/other_user}","gists_url":"https://api.github.com/users/cep21/gists{/gist_id}","starred_url":"https://api.github.com/users/cep21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cep21/subscriptions","organizations_url":"https://api.github.com/users/cep21/orgs","repos_url":"https://api.github.com/users/cep21/repos","events_url":"https://api.github.com/users/cep21/events{/privacy}","received_events_url":"https://api.github.com/users/cep21/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-08T22:01:26Z","updated_at":"2015-12-08T22:12:51Z","closed_at":null,"body":"Hi,\r\n\r\nI think go-kit/kit/log reflects my personal thoughts on logging, but I am hesitant to use it directly due to Logger.log() returning an error.  In my opinion errors are intended to be checked, not ignored.  And it's unreasonable to ask users to check log messages.  I feel a better philosophy is for the formatters/writers that eventually output messages to disk/tcp/stdout/etc to allow registering handlers for error types.  Then, when I setup logging I can say \"Here is a logger that logs JSON to a file.  If there is an error, call this function (maybe try stdout or maybe trigger some application \"debug me\" state).  \r\n\r\nMaybe something like\r\n```\r\ntype jsonLogger struct {\r\n  io.Writer\r\n  onError func(err error, keyvals ...interface{})\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/go-kit/kit/issues/comments/163034696","html_url":"https://github.com/go-kit/kit/issues/164#issuecomment-163034696","issue_url":"https://api.github.com/repos/go-kit/kit/issues/164","id":163034696,"user":{"login":"cep21","id":20358,"avatar_url":"https://avatars.githubusercontent.com/u/20358?v=3","gravatar_id":"","url":"https://api.github.com/users/cep21","html_url":"https://github.com/cep21","followers_url":"https://api.github.com/users/cep21/followers","following_url":"https://api.github.com/users/cep21/following{/other_user}","gists_url":"https://api.github.com/users/cep21/gists{/gist_id}","starred_url":"https://api.github.com/users/cep21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cep21/subscriptions","organizations_url":"https://api.github.com/users/cep21/orgs","repos_url":"https://api.github.com/users/cep21/repos","events_url":"https://api.github.com/users/cep21/events{/privacy}","received_events_url":"https://api.github.com/users/cep21/received_events","type":"User","site_admin":false},"created_at":"2015-12-08T22:12:51Z","updated_at":"2015-12-08T22:12:51Z","body":"As an example, there exist loggers that simply can't return errors.  One such logger would be like this\r\n```\r\ntype bitSetter struct {\r\n  isSet int\r\n}\r\nfunc (b *bitSetter) Log(...keyvals interface{}) {\r\n  if contains(keyvals, \"state\", \"critical\") {\r\n    atomic.StoreInt32(isSet, 1)\r\n  }\r\n}\r\n\r\nfunc (b *bitSetter) getPrometheusMetrics() prometheus.Metric {\r\n  return prometheus.Metric(\"critical_state\", atomic.LoadInt32(isSet))\r\n}\r\n```\r\n\r\nFor the above logger, my monitoring system would be able to tell me if it entered a critical state.  Maybe this is good as a check of last resort if all the loggers are FUBAR (The disk mount is RO for example).  It's impossible for this logger to error out, which implies to me errors are a consequence of individual loggers and not of logging as a concept."}}