Skip to content

Commit ec8dbf3

Browse files
mbolivar-nordiccarlescufi
authored andcommitted
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 <[email protected]>
1 parent ddce583 commit ec8dbf3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scripts/west_commands/run_common.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636
else:
3737
LOG_LEVEL = logging.INFO
3838

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

4042
class WestLogFormatter(logging.Formatter):
4143

4244
def __init__(self):
43-
super().__init__(fmt='%(message)s')
45+
super().__init__(fmt='%(name)s: %(message)s')
4446

4547
class WestLogHandler(logging.Handler):
4648

@@ -59,7 +61,7 @@ def emit(self, record):
5961
elif lvl >= logging.WARNING:
6062
log.wrn(fmt)
6163
elif lvl >= logging.INFO:
62-
log.inf(fmt)
64+
_banner(fmt)
6365
elif lvl >= logging.DEBUG:
6466
log.dbg(fmt)
6567
else:
@@ -192,6 +194,7 @@ def do_run_common(command, args, runner_args, cached_runner_var):
192194
build_dir = _build_dir(args)
193195

194196
if not args.skip_rebuild:
197+
_banner('west {}: rebuilding'.format(command_name))
195198
try:
196199
cmake.run_build(build_dir)
197200
except CalledProcessError:
@@ -226,7 +229,7 @@ def do_run_common(command, args, runner_args, cached_runner_var):
226229
manually, or check your board's documentation for
227230
alternative instructions.""".format(command_name, board)))
228231

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

0 commit comments

Comments
 (0)