On Wed, 2014-04-02 at 16:42 +0800, Zhou Zheng Sheng wrote:
on 2014/04/02 03:53, Aline Manera wrote:
>
> Reviewed-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
>
> On 04/01/2014 02:37 PM, Christy Perez wrote:
>> 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(a)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)
Since the error output can be long and can contain '\n', I think the cmd
should be in the front of the log message. For example,
kimchi_log.error("cmd: %s\nrc: %s\nerror:\n%s",
" ".join(cmd), proc.returncode, error)
I took out the
newline characters since (like I said in the commit
message), I think that makes it a little unclear as to which rc goes
with what when they're sometimes printed a few at a time.
Moreover,
"error: %s returned from cmd: ".join(cmd)
does not look correct. When we call "aStr.join(sequence)", aStr serves
as a delimiter. For example,
Hm. So, that's not what happened in my testing before. It printed like I
thought it would. But I just did some more testing and it did split the
command and use the message as a delimiter!
>>> "|||".join(['1', '2',
'3'])
'1|||2|||3'
If we just want to paste cmd to the end of the message. We can just
debug("error: %s returned from cmd: %s", error, ' '.joinc(cmd))
' '.join(cmd) is perfect. Thanks.
>>
>> if timeout_flag[0]:
>> msg = ("subprocess is killed by signal.SIGKILL for "
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel(a)ovirt.org
>
http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>