{"action":"closed","issue":{"url":"https://api.github.com/repos/inconshreveable/log15/issues/46","labels_url":"https://api.github.com/repos/inconshreveable/log15/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/inconshreveable/log15/issues/46/comments","events_url":"https://api.github.com/repos/inconshreveable/log15/issues/46/events","html_url":"https://github.com/inconshreveable/log15/issues/46","id":55837166,"number":46,"title":"Typed nil pointer in context results in panic","user":{"login":"mobileben","id":536780,"avatar_url":"https://avatars.githubusercontent.com/u/536780?v=3","gravatar_id":"","url":"https://api.github.com/users/mobileben","html_url":"https://github.com/mobileben","followers_url":"https://api.github.com/users/mobileben/followers","following_url":"https://api.github.com/users/mobileben/following{/other_user}","gists_url":"https://api.github.com/users/mobileben/gists{/gist_id}","starred_url":"https://api.github.com/users/mobileben/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mobileben/subscriptions","organizations_url":"https://api.github.com/users/mobileben/orgs","repos_url":"https://api.github.com/users/mobileben/repos","events_url":"https://api.github.com/users/mobileben/events{/privacy}","received_events_url":"https://api.github.com/users/mobileben/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/inconshreveable/log15/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-01-29T00:18:19Z","updated_at":"2015-02-25T03:42:45Z","closed_at":"2015-02-25T03:42:45Z","body":"If you pass a typed nil pointer to the context, \r\n\r\nExample:\r\n\r\nif player is nil\r\n\r\n\t\tlog.Warn(\"Remove issue\", log.Ctx{\"tier\": tier, \"player\": player, \"reason\": \"player does not exist in cache\"})\r\n\r\nYou will get a panic when the struct's auto generated .String is called using a nil pointer.\r\n\r\nThis will happen here:\r\n\r\nformat.go:178\r\n\r\n    func formatShared(value interface{}) interface{} {\r\n    \t    switch v := value.(type) {\r\n\t    case time.Time:\r\n\t\t    return v.Format(timeFormat)\r\n\r\n\t    case error:\r\n\t\t    return v.Error()\r\n\r\n\t    case fmt.Stringer:\r\n\t\t    return v.String()\r\n\r\n\t    default:\r\n\t\t    return v\r\n\t    }\r\n    }\r\n\r\nThis may be a known issue, but I could see accidentally having nil's sent in. From what I have read, to address this, reflect may be needed which would incur an overhead and may not be desired. I thought I'd open this issue to find out if this is deemed an issue. If not, what the best practices are to work around this."}}