Error logging

This commit is contained in:
binwiederhier 2023-02-06 16:01:32 -05:00
parent b5158adb51
commit 9b54f63eb1
5 changed files with 60 additions and 22 deletions

View file

@ -77,7 +77,11 @@ func (e *Event) Time(time time.Time) *Event {
// Err adds an "error" field to the log event
func (e *Event) Err(err error) *Event {
e.fields[errorField] = err.Error()
if c, ok := err.(Contexter); ok {
e.Fields(c.Context())
} else {
e.fields[errorField] = err.Error()
}
return e
}