diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2022-02-02 14:17:38 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-02-03 01:24:57 +0000 |
commit | 94416dde06ff0c9ad524732b293639279c4e9a3d (patch) | |
tree | f5ef7ec055ce9ee09ddb5b776e81d568dec2cf06 | |
parent | e8942461d5c8235a163d8c447472a2dcd48ff2b1 (diff) | |
download | chrome-ec-94416dde06ff0c9ad524732b293639279c4e9a3d.tar.gz |
zephyr: zmake: Disable traceback suppression
As discussed in the logging brainstorming meeting, traceback
suppression only makes it more difficult to fix bugs, determine the
cause of a failure, or make changes in zmake. This is to the point
that much of our documentation has been putting -D everywhere.
While there's much work to go to get rid of -D everywhere so that we
display the right logs when we need them, we can start at getting rid
of the traceback suppression feature and making -D just set
--log-level=DEBUG.
The two options are placed in a mutually-exclusive group such that
specifying --debug/-D and --log-level at the same time is not valid.
BUG=b:217423904
BRANCH=none
TEST=unit tests pass
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: I124b23c307b8b6e82edf4d5e43e2fcff82384a8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3432911
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r-- | zephyr/zmake/README.md | 6 | ||||
-rw-r--r-- | zephyr/zmake/zmake/__main__.py | 39 |
2 files changed, 20 insertions, 25 deletions
diff --git a/zephyr/zmake/README.md b/zephyr/zmake/README.md index b6221ee3a7..8db143638e 100644 --- a/zephyr/zmake/README.md +++ b/zephyr/zmake/README.md @@ -6,7 +6,7 @@ ## Usage -**Usage:** `zmake [-h] [--checkout CHECKOUT] [-D] [-j JOBS] [--goma] [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-L] [--log-label] [--modules-dir MODULES_DIR] [--zephyr-base ZEPHYR_BASE] subcommand ...` +**Usage:** `zmake [-h] [--checkout CHECKOUT] [-j JOBS] [--goma] [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL} | -D] [-L] [--log-label] [--modules-dir MODULES_DIR] [--zephyr-base ZEPHYR_BASE] subcommand ...` Chromium OS's meta-build tool for Zephyr @@ -22,10 +22,10 @@ Chromium OS's meta-build tool for Zephyr |---|---| | `-h`, `--help` | show this help message and exit | | `--checkout CHECKOUT` | Path to ChromiumOS checkout | -| `-D`, `--debug` | Turn on debug features (e.g., stack trace, verbose logging) | | `-j JOBS`, `--jobs JOBS` | Degree of multiprogramming to use | | `--goma` | Enable hyperspeed compilation with Goma! (Googlers only) | -| `-l LOG_LEVEL`, `--log-level LOG_LEVEL` | Set the logging level (default=INFO) | +| `-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}`, `--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}` | Set the logging level (default=INFO) | +| `-D`, `--debug` | Alias for --log-level=DEBUG | | `-L`, `--no-log-label` | Turn off logging labels | | `--log-label` | Turn on logging labels | | `--modules-dir MODULES_DIR` | The path to a directory containing all modules needed. If unspecified, zmake will assume you have a Chrome OS checkout and try locating them in the checkout. | diff --git a/zephyr/zmake/zmake/__main__.py b/zephyr/zmake/zmake/__main__.py index 9136a8aa7a..f2454ec7f3 100644 --- a/zephyr/zmake/zmake/__main__.py +++ b/zephyr/zmake/zmake/__main__.py @@ -107,13 +107,6 @@ def get_argparser(): "--checkout", type=pathlib.Path, help="Path to ChromiumOS checkout" ) parser.add_argument( - "-D", - "--debug", - action="store_true", - default=False, - help=("Turn on debug features (e.g., stack trace, " "verbose logging)"), - ) - parser.add_argument( "-j", "--jobs", # TODO(b/178196029): ninja doesn't know how to talk to a @@ -129,13 +122,26 @@ def get_argparser(): dest="goma", help="Enable hyperspeed compilation with Goma! (Googlers only)", ) - parser.add_argument( + + log_level_group = parser.add_mutually_exclusive_group() + log_level_group.add_argument( "-l", "--log-level", - choices=list(log_level_map.keys()), - dest="log_level", + choices=log_level_map.values(), + metavar=f"{{{','.join(log_level_map)}}}", + type=lambda x: log_level_map[x], + default=logging.INFO, help="Set the logging level (default=INFO)", ) + log_level_group.add_argument( + "-D", + "--debug", + dest="log_level", + action="store_const", + const=logging.DEBUG, + help="Alias for --log-level=DEBUG", + ) + parser.add_argument( "-L", "--no-log-label", @@ -340,16 +346,8 @@ def main(argv=None): opts = parser.parse_args(argv) # Default logging - log_level = logging.INFO log_label = False - if opts.log_level: - log_level = log_level_map[opts.log_level] - log_label = True - elif opts.debug: - log_level = logging.DEBUG - log_label = True - if opts.log_label is not None: log_label = opts.log_label if log_label: @@ -358,10 +356,7 @@ def main(argv=None): log_format = "%(message)s" multiproc.log_job_names = False - logging.basicConfig(format=log_format, level=log_level) - - if not opts.debug: - sys.tracebacklimit = 0 + logging.basicConfig(format=log_format, level=opts.log_level) try: zmake = call_with_namespace(zm.Zmake, opts) |