blackbox: optionally log event source
authortimeless <timeless@mozdev.org>
Thu, 11 Feb 2016 19:38:26 +0000
changeset 28305 f5ae291dfedf
parent 28304 6b38888ab033
child 28306 1778770e1982
blackbox: optionally log event source
hgext/blackbox.py
--- a/hgext/blackbox.py	Tue Mar 01 10:45:47 2016 +0000
+++ b/hgext/blackbox.py	Thu Feb 11 19:38:26 2016 +0000
@@ -18,6 +18,8 @@
   # dirty is *EXPENSIVE* (slow);
   # each log entry indicates `+` if the repository is dirty, like :hg:`id`.
   dirty = True
+  # record the source of log messages
+  logsource = True
 
   [blackbox]
   track = command, commandfinish, commandexception, exthook, pythonhook
@@ -174,9 +176,13 @@
                         any(ctx.sub(s).dirty() for s in ctx.substate)
                     )):
                         changed = '+'
+                if ui.configbool('blackbox', 'logsource', False):
+                    src = ' [%s]' % event
+                else:
+                    src = ''
                 try:
-                    ui._bbwrite('%s %s @%s%s (%s)> %s',
-                        date, user, rev, changed, pid, formattedmsg)
+                    ui._bbwrite('%s %s @%s%s (%s)%s> %s',
+                        date, user, rev, changed, pid, src, formattedmsg)
                 except IOError as err:
                     self.debug('warning: cannot write to blackbox.log: %s\n' %
                                err.strerror)