From 3c1ccb923fc110fa86893b3e7cbbfa0b75c9a4dc Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 22 Jul 2020 09:16:55 -0400 Subject: logs: Prepend current subproject name to all messages Meson used to prepend '|' for each nested subproject to distinguish in the logs where a subproject start and ends. It is more useful to print the current subproject name. Also print the call stack when starting a new subproject to better see which subproject chain leads to to. --- mesonbuild/mlog.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'mesonbuild/mlog.py') diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index 15fdb8d..c1c323b 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -69,7 +69,7 @@ def setup_console() -> None: log_dir = None # type: T.Optional[str] log_file = None # type: T.Optional[T.TextIO] log_fname = 'meson-log.txt' # type: str -log_depth = 0 # type: int +log_depth = [] # type: T.List[str] log_timestamp_start = None # type: T.Optional[float] log_fatal_warnings = False # type: bool log_disable_stdout = False # type: bool @@ -209,8 +209,8 @@ def force_print(*args: str, **kwargs: T.Any) -> None: print(*args, **kwargs) raw = iostr.getvalue() - if log_depth > 0: - prepend = '|' * log_depth + if log_depth: + prepend = log_depth[-1] + '|' raw = prepend + raw.replace('\n', '\n' + prepend, raw.count('\n') - 1) # _Something_ is going to get printed. @@ -370,10 +370,10 @@ def format_list(input_list: T.List[str]) -> str: return '' @contextmanager -def nested() -> T.Generator[None, None, None]: +def nested(name: str = '') -> T.Generator[None, None, None]: global log_depth - log_depth += 1 + log_depth.append(name) try: yield finally: - log_depth -= 1 + log_depth.pop() -- cgit v1.1