From 6bde4d00dd5d1ce62585c3aac10076d53b3d9e1f Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Wed, 14 Apr 2021 13:43:58 -0400 Subject: 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 --- cmd/podman/root.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/podman/root.go b/cmd/podman/root.go index 4527c2646..9e5d2a236 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -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 } -- cgit v1.2.3-54-g00ecf