[JSON] Use type-switch for error field
diff --git a/json_formatter.go b/json_formatter.go index 0e38a61..5c4c44b 100644 --- a/json_formatter.go +++ b/json_formatter.go
@@ -11,11 +11,12 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { data := make(Fields, len(entry.Data)+3) for k, v := range entry.Data { - // Otherwise errors are ignored by `encoding/json` - // https://github.com/Sirupsen/logrus/issues/137 - if err, ok := v.(error); ok { - data[k] = err.Error() - } else { + switch v := v.(type) { + case error: + // Otherwise errors are ignored by `encoding/json` + // https://github.com/Sirupsen/logrus/issues/137 + data[k] = v.Error() + default: data[k] = v } }