summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Cerveau <scerveau@igalia.com>2025-10-25 15:24:48 +0200
committerXavier Claessens <xclaesse@gmail.com>2025-11-03 18:12:56 -0500
commit66e43fa19f93e9f9367cb2008d06ecc0d261ba73 (patch)
treea6827870bc65917fe3c8f9c33c799bde952589ac
parent0514719b3cfadf0c80d10dc6652154c7c2a86bce (diff)
downloadmeson-66e43fa19f93e9f9367cb2008d06ecc0d261ba73.tar.gz
mlog: add a new log file with the setup logs
Add meson-setup.txt to keep the configure log out of the debug logs.
-rw-r--r--docs/markdown/snippets/meson-configure-log.md6
-rw-r--r--mesonbuild/mlog.py12
2 files changed, 18 insertions, 0 deletions
diff --git a/docs/markdown/snippets/meson-configure-log.md b/docs/markdown/snippets/meson-configure-log.md
new file mode 100644
index 000000000..8a1a87654
--- /dev/null
+++ b/docs/markdown/snippets/meson-configure-log.md
@@ -0,0 +1,6 @@
+## Add a configure log in meson-logs
+
+Add a second log file `meson-setup.txt` which contains the configure logs
+displayed on stdout during the meson `setup` stage.
+It allows user to navigate through the setup logs without searching in the terminal
+or the extensive informations of `meson-log.txt`. \ No newline at end of file
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index 86ac0d102..e1d998a5d 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -67,6 +67,7 @@ class _Logger:
log_depth: T.List[str] = field(default_factory=list)
log_to_stderr: bool = False
log_file: T.Optional[T.TextIO] = None
+ slog_file: T.Optional[T.TextIO] = None
log_timestamp_start: T.Optional[float] = None
log_fatal_warnings = False
log_disable_stdout = False
@@ -76,6 +77,7 @@ class _Logger:
log_pager: T.Optional['subprocess.Popen'] = None
_LOG_FNAME: T.ClassVar[str] = 'meson-log.txt'
+ _SLOG_FNAME: T.ClassVar[str] = 'meson-setup.txt'
@contextmanager
def no_logging(self) -> T.Iterator[None]:
@@ -110,6 +112,12 @@ class _Logger:
self.log_file = None
exception_around_goer.close()
return path
+ if self.slog_file is not None:
+ path = self.slog_file.name
+ exception_around_goer = self.slog_file
+ self.slog_file = None
+ exception_around_goer.close()
+ return path
self.stop_pager()
return None
@@ -164,6 +172,7 @@ class _Logger:
def initialize(self, logdir: str, fatal_warnings: bool = False) -> None:
self.log_dir = logdir
self.log_file = open(os.path.join(logdir, self._LOG_FNAME), 'w', encoding='utf-8')
+ self.slog_file = open(os.path.join(logdir, self._SLOG_FNAME), 'w', encoding='utf-8')
self.log_fatal_warnings = fatal_warnings
def process_markup(self, args: T.Sequence[TV_Loggable], keep: bool, display_timestamp: bool = True) -> T.List[str]:
@@ -224,6 +233,9 @@ class _Logger:
if self.log_file is not None:
print(*arr, file=self.log_file, sep=sep, end=end)
self.log_file.flush()
+ if self.slog_file is not None:
+ print(*arr, file=self.slog_file, sep=sep, end=end)
+ self.slog_file.flush()
if self.colorize_console():
arr = process_markup(args, True, display_timestamp)
if not self.log_errors_only or is_error: