From: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
run_command logs stdout and stderr output using the "debug" level. In
this patch, if returncode is non-zero, it logs stderr output using the
"error" level. It's helpful for diagnosing underlying command errors.
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
---
src/kimchi/utils.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
index d4ab1a1..e89a93f 100644
--- a/src/kimchi/utils.py
+++ b/src/kimchi/utils.py
@@ -169,8 +169,13 @@ def run_command(cmd, timeout=None):
out, error = proc.communicate()
kimchi_log.debug("Run command: '%s'", " ".join(cmd))
- if out or error:
- kimchi_log.debug("out:\n %s\nerror:\n %s", out, error)
+ if out:
+ kimchi_log.debug("out:\n%s", out)
+
+ if proc.returncode != 0:
+ kimchi_log.error("rc: %s\nerror:\n%s", proc.returncode, error)
+ elif error:
+ kimchi_log.debug("error:\n%s", error)
if timeout_flag[0]:
msg = ("subprocess is killed by signal.SIGKILL for "
--
1.8.5.3