diff --git a/logs/logs.go b/logs/logs.go index 804988b8faa96e53e609538042d0c2b5d14ce60a..d9aaf9fda10ad62329f0f71ea71bb4dbf6d1c0a4 100644 --- a/logs/logs.go +++ b/logs/logs.go @@ -226,7 +226,7 @@ func Info(format string, a ...interface{}) { } } -func ErrorWithFields(fields map[string]interface{}, err error) { +func ErrorWithFields(err error, fields map[string]interface{}) { if disableLogging { return } @@ -242,17 +242,20 @@ func ErrorWithFields(fields map[string]interface{}, err error) { } } -func ErrorWithMsg(message string, err error) { +func ErrorWithMsg(err error, format string, a ...interface{}) { if disableLogging { return } + message := fmt.Sprintf(format, a...) + if err == nil { err = errors.Error(message) } - ErrorWithFields(map[string]interface{}{ + + ErrorWithFields(err, map[string]interface{}{ "message": message, - }, err) + }) } func ErrorMsg(format string, a ...interface{}) { @@ -262,7 +265,7 @@ func ErrorMsg(format string, a ...interface{}) { message := SanitiseLogs(fmt.Sprintf(format, a...)) - ErrorWithMsg(message, nil) + ErrorWithMsg(nil, message) } func Warn(format string, a ...interface{}) { @@ -280,7 +283,7 @@ func Warn(format string, a ...interface{}) { } } -func WarnWithFields(fields map[string]interface{}, err error) { +func WarnWithFields(err error, fields map[string]interface{}) { if disableLogging { return }