[Kimchi-devel] [PATCH] run_command: log error messages using higher log level when return code is non-zero

zhshzhou at linux.vnet.ibm.com zhshzhou at linux.vnet.ibm.com
Wed Feb 26 04:02:04 UTC 2014


From: Zhou Zheng Sheng <zhshzhou at 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 at 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




More information about the Kimchi-devel mailing list