From 42c9c252631976f332cb1683d76147bd8cde22bd Mon Sep 17 00:00:00 2001 From: Graham Hughes Date: Sat, 21 Nov 2015 22:59:38 -0800 Subject: [PATCH] Support `WithError` on `Logger`. Should address #277. --- logger.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/logger.go b/logger.go index fd9804c..2fdb231 100644 --- a/logger.go +++ b/logger.go @@ -64,6 +64,12 @@ func (logger *Logger) WithFields(fields Fields) *Entry { return NewEntry(logger).WithFields(fields) } +// Add an error as single field to the log entry. All it does is call +// `WithError` for the given `error`. +func (logger *Logger) WithError(err error) *Entry { + return NewEntry(logger).WithError(err) +} + func (logger *Logger) Debugf(format string, args ...interface{}) { if logger.Level >= DebugLevel { NewEntry(logger).Debugf(format, args...)