diff options
author | Harmen Stoppels <harmenstoppels@gmail.com> | 2022-10-24 03:12:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-23 18:12:38 -0700 |
commit | 7d99fbcafd4720babe2a0d325df099ed9056f5e1 (patch) | |
tree | e369403ebb5808e3984db5c23fbf8b8fd1edfb2f /lib | |
parent | 6c32c6fbdba52109de9f112dfe785c66b7d114e8 (diff) | |
download | spack-7d99fbcafd4720babe2a0d325df099ed9056f5e1.tar.gz spack-7d99fbcafd4720babe2a0d325df099ed9056f5e1.tar.bz2 spack-7d99fbcafd4720babe2a0d325df099ed9056f5e1.tar.xz spack-7d99fbcafd4720babe2a0d325df099ed9056f5e1.zip |
backtraces with --backtrace (#33478)
* backtraces without --debug
Currently `--debug` is too verbose and not-`--debug` gives to little
context about where exceptions are coming from.
So, instead, it'd be nice to have `spack --backtrace` and
`SPACK_BACKTRACE=1` as methods to get something inbetween: no verbose
debug messages, but always a full backtrace.
This is useful for CI, where we don't want to drown in debug messages
when installing deps, but we do want to get details where something goes
wrong if it goes wrong.
* completion
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/main.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py index 7e84be5781..998d0e2022 100644 --- a/lib/spack/spack/main.py +++ b/lib/spack/spack/main.py @@ -528,6 +528,12 @@ def make_argument_parser(**kwargs): help="add stacktraces to all printed statements", ) parser.add_argument( + "--backtrace", + action="store_true", + default="SPACK_BACKTRACE" in os.environ, + help="always show backtraces for exceptions", + ) + parser.add_argument( "-V", "--version", action="store_true", help="show version number and exit" ) parser.add_argument( @@ -561,8 +567,10 @@ def setup_main_options(args): # debug must be set first so that it can even affect behavior of # errors raised by spack.config. + if args.debug or args.backtrace: + spack.error.debug = True + if args.debug: - spack.error.debug = args.debug spack.util.debug.register_interrupt_handler() spack.config.set("config:debug", True, scope="command_line") spack.util.environment.tracing_enabled = True |