mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-12 14:51:56 +00:00
Update to the latest west. This includes a new 'attach' command. There are also multi-repo commands, but those won't get exposed to the user unless they install Zephyr using "west init" + "west fetch" (and not, say, "git clone"). Replace the launchers; they now detect whether zephyr is part of a multi-repo installation, and run the west code in its own repository if that is the case. This also requires an update to: - the flash/debug CMakeLists.txt, as the new west package is no longer executable as a module and must have its main script run by the interpreter instead. - the documentation, to reflect a rename and with a hack to fix the automodule directive in flash-debug.rst for now Signed-off-by: Marti Bolivar <marti@foundries.io>
86 lines
2.3 KiB
Python
86 lines
2.3 KiB
Python
# Copyright 2018 Open Source Foundries Limited.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
'''Logging module for west
|
|
|
|
Provides common methods for logging messages to display to the user.'''
|
|
|
|
import colorama
|
|
import sys
|
|
|
|
VERBOSE_NONE = 0
|
|
'''Base verbosity level (zero), no verbose messages printed.'''
|
|
|
|
VERBOSE_NORMAL = 1
|
|
'''Base verbosity level, some verbose messages printed.'''
|
|
|
|
VERBOSE_VERY = 2
|
|
'''Very verbose output messages will be printed.'''
|
|
|
|
VERBOSE_EXTREME = 3
|
|
'''Extremely verbose output messages will be printed.'''
|
|
|
|
VERBOSE = VERBOSE_NONE
|
|
'''Global verbosity level. VERBOSE_NONE is the default.'''
|
|
|
|
|
|
def set_verbosity(value):
|
|
'''Set the logging verbosity level.'''
|
|
global VERBOSE
|
|
VERBOSE = int(value)
|
|
|
|
|
|
def dbg(*args, level=VERBOSE_NORMAL):
|
|
'''Print a verbose debug logging message.
|
|
|
|
The message is only printed if level is at least the current
|
|
verbosity level.'''
|
|
if level > VERBOSE:
|
|
return
|
|
print(*args)
|
|
|
|
|
|
def inf(*args, colorize=False):
|
|
'''Print an informational message.
|
|
|
|
colorize (default: False):
|
|
If True, the message is printed in bright green if stdout is a terminal.
|
|
'''
|
|
# This approach colorizes any sep= and end= text too, as expected.
|
|
#
|
|
# colorama automatically strips the ANSI escapes when stdout isn't a
|
|
# terminal (by wrapping sys.stdout).
|
|
if colorize:
|
|
print(colorama.Fore.LIGHTGREEN_EX, end='')
|
|
|
|
print(*args)
|
|
|
|
if colorize:
|
|
# The final flush=True avoids issues with unrelated output from
|
|
# commands (usually Git) becoming green, due to the final attribute
|
|
# reset ANSI escape getting line-buffered.
|
|
print(colorama.Style.RESET_ALL, end='', flush=True)
|
|
|
|
|
|
def wrn(*args):
|
|
'''Print a warning.'''
|
|
print(colorama.Fore.LIGHTRED_EX + 'WARNING: ', end='', file=sys.stderr)
|
|
print(*args, file=sys.stderr)
|
|
print(colorama.Style.RESET_ALL, end='', file=sys.stderr, flush=True)
|
|
|
|
|
|
def err(*args, fatal=False):
|
|
'''Print an error.'''
|
|
print(colorama.Fore.LIGHTRED_EX
|
|
+ ('FATAL ERROR: ' if fatal else 'ERROR: '),
|
|
end='', file=sys.stderr)
|
|
print(*args, file=sys.stderr)
|
|
print(colorama.Style.RESET_ALL, end='', file=sys.stderr, flush=True)
|
|
|
|
|
|
def die(*args, exit_code=1):
|
|
'''Print a fatal error, and abort with the given exit code.'''
|
|
err(*args, fatal=True)
|
|
sys.exit(exit_code)
|