logger: fix nil pointer deref in WithError

fixes #9
This commit is contained in:
Christian Schwarz 2017-10-05 21:23:39 +02:00
parent 161ce3b3c3
commit 493a01c4fe

View File

@ -102,7 +102,11 @@ func (l *Logger) WithFields(fields Fields) (ret *Logger) {
}
func (l *Logger) WithError(err error) *Logger {
return l.WithField(FieldError, err.Error())
val := interface{}(nil)
if err != nil {
val = err.Error()
}
return l.WithField(FieldError, val)
}
func (l *Logger) Debug(msg string) {