logger: Include msg in object serialization error (#6650)
Include the `msg` for additional context when JSON serialization of the log object fails.
This commit is contained in:
parent
595a9511ed
commit
60eb2145ec
|
|
@ -320,7 +320,7 @@ func (log *impl) Infof(format string, a ...interface{}) {
|
||||||
func (log *impl) InfoObject(msg string, obj interface{}) {
|
func (log *impl) InfoObject(msg string, obj interface{}) {
|
||||||
jsonObj, err := json.Marshal(obj)
|
jsonObj, err := json.Marshal(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.auditAtLevel(syslog.LOG_ERR, fmt.Sprintf("Object could not be serialized to JSON. Raw: %+v", obj))
|
log.auditAtLevel(syslog.LOG_ERR, fmt.Sprintf("Object for msg %q could not be serialized to JSON. Raw: %+v", msg, obj))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -354,7 +354,7 @@ func (log *impl) AuditInfof(format string, a ...interface{}) {
|
||||||
func (log *impl) AuditObject(msg string, obj interface{}) {
|
func (log *impl) AuditObject(msg string, obj interface{}) {
|
||||||
jsonObj, err := json.Marshal(obj)
|
jsonObj, err := json.Marshal(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.auditAtLevel(syslog.LOG_ERR, fmt.Sprintf("Object could not be serialized to JSON. Raw: %+v", obj))
|
log.auditAtLevel(syslog.LOG_ERR, fmt.Sprintf("Object for msg %q could not be serialized to JSON. Raw: %+v", msg, obj))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue