diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-07-22 09:16:55 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2021-03-22 21:29:14 -0400 |
commit | 3c1ccb923fc110fa86893b3e7cbbfa0b75c9a4dc (patch) | |
tree | e1159c68d5f7280a29d35612d9a7c3130e801a3f | |
parent | ea48edbb0fcd567b26d94e27b9b61612f56728f5 (diff) | |
download | meson-3c1ccb923fc110fa86893b3e7cbbfa0b75c9a4dc.tar.gz |
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.
-rw-r--r-- | mesonbuild/interpreter.py | 13 | ||||
-rw-r--r-- | mesonbuild/mlog.py | 12 |
2 files changed, 13 insertions, 12 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 5cf3dde9a..2e4444ccd 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2912,8 +2912,9 @@ external dependencies (including libraries) must go to "dependencies".''') self.global_args_frozen = True mlog.log() - with mlog.nested(): - mlog.log('Executing subproject', mlog.bold(subp_name), 'method', mlog.bold(method), '\n') + with mlog.nested(subp_name): + stack = ':'.join(self.subproject_stack + [subp_name]) + mlog.log('Executing subproject', mlog.bold(stack), 'method', mlog.bold(method), '\n') try: if method == 'meson': return self._do_subproject_meson(subp_name, subdir, default_options, kwargs) @@ -2926,7 +2927,7 @@ external dependencies (including libraries) must go to "dependencies".''') raise except Exception as e: if not required: - with mlog.nested(): + with mlog.nested(subp_name): # Suppress the 'ERROR:' prefix because this exception is not # fatal and VS CI treat any logs with "ERROR:" as fatal. mlog.exception(e, prefix=mlog.yellow('Exception:')) @@ -2938,7 +2939,7 @@ external dependencies (including libraries) must go to "dependencies".''') ast: T.Optional[mparser.CodeBlockNode] = None, build_def_files: T.Optional[T.List[str]] = None, is_translated: bool = False) -> SubprojectHolder: - with mlog.nested(): + with mlog.nested(subp_name): new_build = self.build.copy() subi = Interpreter(new_build, self.backend, subp_name, subdir, self.subproject_dir, self.modules, default_options, ast=ast, is_translated=is_translated) @@ -2975,7 +2976,7 @@ external dependencies (including libraries) must go to "dependencies".''') return self.subprojects[subp_name] def _do_subproject_cmake(self, subp_name, subdir, subdir_abs, default_options, kwargs): - with mlog.nested(): + with mlog.nested(subp_name): new_build = self.build.copy() prefix = self.coredata.options[OptionKey('prefix')].value @@ -2995,7 +2996,7 @@ external dependencies (including libraries) must go to "dependencies".''') ast = cm_int.pretend_to_be_meson(options.target_options) mlog.log() - with mlog.nested(): + with mlog.nested('cmake-ast'): mlog.log('Processing generated meson AST') # Debug print the generated meson file diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index 15fdb8d14..c1c323ba7 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() |