summaryrefslogtreecommitdiff
path: root/morphlib/app.py
diff options
context:
space:
mode:
authorTiago Gomes <tiago.gomes@codethink.co.uk>2015-08-13 15:07:50 +0000
committerTiago Gomes <tiago.gomes@codethink.co.uk>2015-09-01 15:19:06 +0000
commitf68a622ea0ab438f699fcd5e29f6c4167c59029e (patch)
tree96b5141c4783bce51c3ce2901dbebc7fa5383e69 /morphlib/app.py
parent29d6b3d36e40317ab72bd543b7d644161906b723 (diff)
downloadmorph-tiagogomes/improve-debugging.tar.gz
Improve build loggingtiagogomes/improve-debugging
Change-Id: If9a6b17797166c295f3c597cc6d17226d45957e7
Diffstat (limited to 'morphlib/app.py')
-rw-r--r--morphlib/app.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index 8fd52a46..187675cd 100644
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -342,7 +342,12 @@ class Morph(cliapp.Application):
'''
assert 'msg' in kwargs
- text = self.status_prefix + (kwargs['msg'] % kwargs)
+ msg = kwargs['msg'] % kwargs
+
+ logger = logging.getLogger()
+ fmt = '%(asctime)s %(levelname)s ' + self.status_prefix + '%(message)s'
+ datefmt = self.setup_logging_timestamp()
+ logger.handlers[0].setFormatter(logging.Formatter(fmt, datefmt))
error = kwargs.get('error', False)
chatty = kwargs.get('chatty', False)
@@ -350,15 +355,15 @@ class Morph(cliapp.Application):
debug = self.settings['debug']
if error:
- logging.error(text)
+ logging.error(msg)
elif chatty:
- logging.debug(text)
+ logging.debug(msg)
else:
- logging.info(text)
+ logging.info(msg)
ok = debug or error or (not quiet and not chatty)
if ok:
- self._write_status(text)
+ self._write_status("%s%s" % (self.status_prefix, msg))
def _commandline_as_message(self, argv, args):
'''Create a status string for a command that's about to be executed.'''