Skip to content
Browse files

scripts: tweak runner-related command output

Having common log handlers now lets us improve our logging output so
that info messages are prefixed with the runner they came from, and
doing something similar with the high level steps as we go, like this:

   -- west <command>: using runners
   -- runners.RUNNER_NAME: doing something
   <output from RUNNER_NAME subprocesses go here>
   -- runners.RUNNER_NAME: all done, bye

We can also colorize the west output to make it stand out better from
subprocesses, using the same output formatting style that west
commands like west list do.

Signed-off-by: Marti Bolivar <>
  • Loading branch information...
mbolivar authored and carlescufi committed Jun 3, 2019
1 parent ddce583 commit ec8dbf34dc4259f0b8bb114972057f40346723c6
Showing with 6 additions and 3 deletions.
  1. +6 −3 scripts/west_commands/
@@ -36,11 +36,13 @@
LOG_LEVEL = logging.INFO

def _banner(msg):
log.inf('-- ' + msg, colorize=True)

class WestLogFormatter(logging.Formatter):

def __init__(self):
super().__init__(fmt='%(name)s: %(message)s')

class WestLogHandler(logging.Handler):

@@ -59,7 +61,7 @@ def emit(self, record):
elif lvl >= logging.WARNING:
elif lvl >= logging.INFO:
elif lvl >= logging.DEBUG:
@@ -192,6 +194,7 @@ def do_run_common(command, args, runner_args, cached_runner_var):
build_dir = _build_dir(args)

if not args.skip_rebuild:
_banner('west {}: rebuilding'.format(command_name))
except CalledProcessError:
@@ -226,7 +229,7 @@ def do_run_common(command, args, runner_args, cached_runner_var):
manually, or check your board's documentation for
alternative instructions.""".format(command_name, board)))

log.inf('Using runner:', runner)
_banner('west {}: using runner {}'.format(command_name, runner))
if runner not in available:
log.wrn('Runner {} is not configured for use with {}, '
'this may not work'.format(runner, board))

0 comments on commit ec8dbf3

Please sign in to comment.
You can’t perform that action at this time.