From 8cd4d0b2832666f19660b9006040e5ff7e5d4576 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 10 Mar 2021 14:19:48 -0500 Subject: [PATCH] mlog: Do not print 'subproject|' for the message 'Executing subproject' It already contains the full callstack and it's more visible when it's standing on its own line. --- mesonbuild/interpreter.py | 12 +++++------- mesonbuild/mlog.py | 7 ++++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 8653b385e..4dcb48cbe 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2911,13 +2911,11 @@ external dependencies (including libraries) must go to "dependencies".''') os.makedirs(os.path.join(self.build.environment.get_build_dir(), subdir), exist_ok=True) self.global_args_frozen = True - mlog.log() - with mlog.nested(subp_name): - stack = ':'.join(self.subproject_stack + [subp_name]) - m = ['Executing subproject', mlog.bold(stack)] - if method != 'meson': - m += ['method', mlog.bold(method)] - mlog.log(*m,'\n') + stack = ':'.join(self.subproject_stack + [subp_name]) + m = ['\nExecuting subproject', mlog.bold(stack)] + if method != 'meson': + m += ['method', mlog.bold(method)] + mlog.log(*m,'\n', nested=False) try: if method == 'meson': diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index c51922aa7..38a4805b3 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -201,7 +201,7 @@ def process_markup(args: T.Sequence[T.Union[AnsiDecorator, str]], keep: bool) -> arr.append(str(arg)) return arr -def force_print(*args: str, **kwargs: T.Any) -> None: +def force_print(*args: str, nested: str, **kwargs: T.Any) -> None: if log_disable_stdout: return iostr = io.StringIO() @@ -210,7 +210,7 @@ def force_print(*args: str, **kwargs: T.Any) -> None: raw = iostr.getvalue() if log_depth: - prepend = log_depth[-1] + '| ' + prepend = log_depth[-1] + '| ' if nested else '' lines = [] for l in raw.split('\n'): l = l.strip() @@ -250,6 +250,7 @@ def log(*args: T.Union[str, AnsiDecorator], is_error: bool = False, def _log(*args: T.Union[str, AnsiDecorator], is_error: bool = False, **kwargs: T.Any) -> None: + nested = kwargs.pop('nested', True) arr = process_markup(args, False) if log_file is not None: print(*arr, file=log_file, **kwargs) @@ -257,7 +258,7 @@ def _log(*args: T.Union[str, AnsiDecorator], is_error: bool = False, if colorize_console(): arr = process_markup(args, True) if not log_errors_only or is_error: - force_print(*arr, **kwargs) + force_print(*arr, nested=nested, **kwargs) def log_once(*args: T.Union[str, AnsiDecorator], is_error: bool = False, **kwargs: T.Any) -> None: