summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-04-23 13:52:12 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-04-23 13:52:12 +0100
commitc353664cdfe3ad1e926ed9a3f00c76955c5cae36 (patch)
treef88f2b915369e560f4c8009efd3db667281915d8
parent8d740a4bdd34f095e530c17ef5eb3f182fb566a7 (diff)
downloadmorph-c353664cdfe3ad1e926ed9a3f00c76955c5cae36.tar.gz
Log command output at debug level if there was no error
-rw-r--r--morphlib/execute.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/morphlib/execute.py b/morphlib/execute.py
index c3c331ee..71053faa 100644
--- a/morphlib/execute.py
+++ b/morphlib/execute.py
@@ -98,11 +98,13 @@ class Execute(object):
out, err = p.communicate(feed_stdin)
if _log: # pragma: no cover
- logging.error('Exit code: %d' % p.returncode)
- logging.error('Standard output:\n%s' %
- morphlib.util.indent(out or ''))
- logging.error('Standard error:\n%s' %
- morphlib.util.indent(err or ''))
+ if p.returncode == 0:
+ logger = logging.debug
+ else:
+ logger = logging.error
+ logger('Exit code: %d' % p.returncode)
+ logger('Standard output:\n%s' % morphlib.util.indent(out or ''))
+ logger('Standard error:\n%s' % morphlib.util.indent(err or ''))
if p.returncode != 0:
raise CommandFailure(' '.join(argv), out)
else: