Skip to content
Snippets Groups Projects
Commit 82320944 authored by Francé Wilke's avatar Francé Wilke
Browse files

Change ErrorWithMsg and ErrorWithFields to cater for formatting directives

parent 413c354e
Branches
Tags v1.272.0
No related merge requests found
...@@ -226,7 +226,7 @@ func Info(format string, a ...interface{}) { ...@@ -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 { if disableLogging {
return return
} }
...@@ -242,17 +242,20 @@ func ErrorWithFields(fields map[string]interface{}, err error) { ...@@ -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 { if disableLogging {
return return
} }
message := fmt.Sprintf(format, a...)
if err == nil { if err == nil {
err = errors.Error(message) err = errors.Error(message)
} }
ErrorWithFields(map[string]interface{}{
ErrorWithFields(err, map[string]interface{}{
"message": message, "message": message,
}, err) })
} }
func ErrorMsg(format string, a ...interface{}) { func ErrorMsg(format string, a ...interface{}) {
...@@ -262,7 +265,7 @@ func ErrorMsg(format string, a ...interface{}) { ...@@ -262,7 +265,7 @@ func ErrorMsg(format string, a ...interface{}) {
message := SanitiseLogs(fmt.Sprintf(format, a...)) message := SanitiseLogs(fmt.Sprintf(format, a...))
ErrorWithMsg(message, nil) ErrorWithMsg(nil, message)
} }
func Warn(format string, a ...interface{}) { func Warn(format string, a ...interface{}) {
...@@ -280,7 +283,7 @@ 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 { if disableLogging {
return return
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment