Mercurial > hg-stable
changeset 50781:4323af38e3f2 stable
blackbox: add a option to duplicate output to stderr too
This is useful when debugging some performance operation.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 22 Jun 2023 19:41:26 +0200 |
parents | 98a7f325eb5d |
children | 75d3306fbc9a |
files | hgext/blackbox.py |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/blackbox.py Fri Jun 23 17:22:42 2023 +0200 +++ b/hgext/blackbox.py Thu Jun 22 19:41:26 2023 +0200 @@ -95,6 +95,13 @@ b'track', default=lambda: [b'*'], ) +# Debug config option that also display the blackbox output on stderr +# (in addition to writing it to disk) +configitem( + b'blackbox', + b'debug.to-stderr', + default=False, +) configitem( b'blackbox', b'ignore', @@ -134,6 +141,7 @@ def _log(self, ui, event, msg, opts): default = ui.configdate(b'devel', b'default-date') dateformat = ui.config(b'blackbox', b'date-format') + debug_to_stderr = ui.configbool(b'blackbox', b'debug.to-stderr') if dateformat: date = dateutil.datestr(default, dateformat) else: @@ -165,7 +173,10 @@ maxfiles=self._maxfiles, maxsize=self._maxsize, ) as fp: - fp.write(fmt % args) + msg = fmt % args + fp.write(msg) + if debug_to_stderr: + ui.write_err(msg) except (IOError, OSError) as err: # deactivate this to avoid failed logging again self._trackedevents.clear()