diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2023-01-22 16:40:14 -0500 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2023-02-06 23:37:55 +0530 |
commit | f8f2f16d825c1990b877e1802b680810c7bd907d (patch) | |
tree | 77fcc81b6785e52647d69a246b08ee0129f62e15 | |
parent | 03e2c70525819a4896c788d91579bf2b201f5985 (diff) | |
download | meson-f8f2f16d825c1990b877e1802b680810c7bd907d.zip meson-f8f2f16d825c1990b877e1802b680810c7bd907d.tar.gz meson-f8f2f16d825c1990b877e1802b680810c7bd907d.tar.bz2 |
mlog: do not squelch console output for errors
We have functionality to squelch logging, and we use this for situations
where we run a fake interpreter and then emit output. e.g. `introspect`.
It's reasonable to avoid logging your bog-standard noisy `mlog.log()`
here, but unfortunately, we also avoided logging the output of
`mlog.exception()` followed by `sys.exit(2)`, because that went through
mlog! :P Special-case this to keep on printing, even if mlog.disable()
was used -- in such a case, we really do want to emit log output no
matter what. Users need this info to ensure they have any clue why Meson
returned a non-zero exit code.
-rw-r--r-- | mesonbuild/mlog.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index 2b310ec..e9c4017 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -384,7 +384,13 @@ def exception(e: Exception, prefix: T.Optional[AnsiDecorator] = None) -> None: if prefix: args.append(prefix) args.append(str(e)) - log(*args) + + restore = log_disable_stdout + if restore: + enable() + log(*args, is_error=True) + if restore: + disable() # Format a list for logging purposes as a string. It separates # all but the last item with commas, and the last with 'and'. |