[Kimchi-devel] [PATCH] Add the command to run_command error and debug logging

Christy Perez christy at linux.vnet.ibm.com
Tue Apr 1 17:37:25 UTC 2014


I was debugging an issue and seeing rc's but not completely
sure which command they were caused by. I think it's just nice
to include what generated an rc, and also have all the output
on the same line to remove any uncertainty.

For example, instead of:

rc: -15
error:

rc: -15
error:

You'll see:
rc: -15  error:  returned from cmd: /usr/bin/example-command-here

Signed-off-by: Christy Perez <christy at linux.vnet.ibm.com>
---
 src/kimchi/utils.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
index 6c29e0e..11a36a4 100644
--- a/src/kimchi/utils.py
+++ b/src/kimchi/utils.py
@@ -174,9 +174,11 @@ def run_command(cmd, timeout=None):
             kimchi_log.debug("out:\n%s", out)
 
         if proc.returncode != 0:
-            kimchi_log.error("rc: %s\nerror:\n%s", proc.returncode, error)
+            kimchi_log.error("rc: %s error: %s returned from cmd:".join(cmd),
+                             proc.returncode, error)
         elif error:
-            kimchi_log.debug("error:\n%s", error)
+            kimchi_log.debug("error: %s returned from cmd: ".join(cmd),
+                              error, cmd)
 
         if timeout_flag[0]:
             msg = ("subprocess is killed by signal.SIGKILL for "
-- 
1.8.5.3




More information about the Kimchi-devel mailing list