blackbox: add a option to duplicate output to stderr too
This is useful when debugging some performance operation.
--- 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()