At trace log level, print error text using %+v instead of %v

If we're logging at trace level, use %+v instead of %v when printing an
error at exit.  If the error included stack information, this will cause
the backtrace to be printed, which is very handy for debugging.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai
2021-04-14 13:43:58 -04:00
parent 9b3226a80a
commit 6bde4d00dd

View File

@ -416,7 +416,11 @@ func formatError(err error) string {
strings.TrimSuffix(err.Error(), ": "+define.ErrOCIRuntime.Error()),
)
} else {
message = "Error: " + err.Error()
if logrus.IsLevelEnabled(logrus.TraceLevel) {
message = fmt.Sprintf("Error: %+v", err)
} else {
message = fmt.Sprintf("Error: %v", err)
}
}
return message
}