# HG changeset patch # User Pierre-Yves David # Date 1687455686 -7200 # Node ID 4323af38e3f2eeb20adb015ef66c6a5869532d89 # Parent 98a7f325eb5de883e38f3923718d4aff5c415396 blackbox: add a option to duplicate output to stderr too This is useful when debugging some performance operation. diff -r 98a7f325eb5d -r 4323af38e3f2 hgext/blackbox.py --- 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()