Skip to content

Commit 66e43fa

Browse files
dabrain34xclaesse
authored andcommitted
mlog: add a new log file with the setup logs
Add meson-setup.txt to keep the configure log out of the debug logs.
1 parent 0514719 commit 66e43fa

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Add a configure log in meson-logs
2+
3+
Add a second log file `meson-setup.txt` which contains the configure logs
4+
displayed on stdout during the meson `setup` stage.
5+
It allows user to navigate through the setup logs without searching in the terminal
6+
or the extensive informations of `meson-log.txt`.

mesonbuild/mlog.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class _Logger:
6767
log_depth: T.List[str] = field(default_factory=list)
6868
log_to_stderr: bool = False
6969
log_file: T.Optional[T.TextIO] = None
70+
slog_file: T.Optional[T.TextIO] = None
7071
log_timestamp_start: T.Optional[float] = None
7172
log_fatal_warnings = False
7273
log_disable_stdout = False
@@ -76,6 +77,7 @@ class _Logger:
7677
log_pager: T.Optional['subprocess.Popen'] = None
7778

7879
_LOG_FNAME: T.ClassVar[str] = 'meson-log.txt'
80+
_SLOG_FNAME: T.ClassVar[str] = 'meson-setup.txt'
7981

8082
@contextmanager
8183
def no_logging(self) -> T.Iterator[None]:
@@ -110,6 +112,12 @@ def shutdown(self) -> T.Optional[str]:
110112
self.log_file = None
111113
exception_around_goer.close()
112114
return path
115+
if self.slog_file is not None:
116+
path = self.slog_file.name
117+
exception_around_goer = self.slog_file
118+
self.slog_file = None
119+
exception_around_goer.close()
120+
return path
113121
self.stop_pager()
114122
return None
115123

@@ -164,6 +172,7 @@ def stop_pager(self) -> None:
164172
def initialize(self, logdir: str, fatal_warnings: bool = False) -> None:
165173
self.log_dir = logdir
166174
self.log_file = open(os.path.join(logdir, self._LOG_FNAME), 'w', encoding='utf-8')
175+
self.slog_file = open(os.path.join(logdir, self._SLOG_FNAME), 'w', encoding='utf-8')
167176
self.log_fatal_warnings = fatal_warnings
168177

169178
def process_markup(self, args: T.Sequence[TV_Loggable], keep: bool, display_timestamp: bool = True) -> T.List[str]:
@@ -224,6 +233,9 @@ def _log(self, *args: TV_Loggable, is_error: bool = False,
224233
if self.log_file is not None:
225234
print(*arr, file=self.log_file, sep=sep, end=end)
226235
self.log_file.flush()
236+
if self.slog_file is not None:
237+
print(*arr, file=self.slog_file, sep=sep, end=end)
238+
self.slog_file.flush()
227239
if self.colorize_console():
228240
arr = process_markup(args, True, display_timestamp)
229241
if not self.log_errors_only or is_error:

0 commit comments

Comments
 (0)