comparison hgext/blackbox.py @ 28305:f5ae291dfedf

blackbox: optionally log event source
author timeless <timeless@mozdev.org>
date Thu, 11 Feb 2016 19:38:26 +0000
parents 6b38888ab033
children 63da8bd0c65e
comparison
equal deleted inserted replaced
28304:6b38888ab033 28305:f5ae291dfedf
16 [blackbox] 16 [blackbox]
17 track = * 17 track = *
18 # dirty is *EXPENSIVE* (slow); 18 # dirty is *EXPENSIVE* (slow);
19 # each log entry indicates `+` if the repository is dirty, like :hg:`id`. 19 # each log entry indicates `+` if the repository is dirty, like :hg:`id`.
20 dirty = True 20 dirty = True
21 # record the source of log messages
22 logsource = True
21 23
22 [blackbox] 24 [blackbox]
23 track = command, commandfinish, commandexception, exthook, pythonhook 25 track = command, commandfinish, commandexception, exthook, pythonhook
24 26
25 [blackbox] 27 [blackbox]
172 if (ui.configbool('blackbox', 'dirty', False) and ( 174 if (ui.configbool('blackbox', 'dirty', False) and (
173 any(ui._bbrepo.status()) or 175 any(ui._bbrepo.status()) or
174 any(ctx.sub(s).dirty() for s in ctx.substate) 176 any(ctx.sub(s).dirty() for s in ctx.substate)
175 )): 177 )):
176 changed = '+' 178 changed = '+'
177 try: 179 if ui.configbool('blackbox', 'logsource', False):
178 ui._bbwrite('%s %s @%s%s (%s)> %s', 180 src = ' [%s]' % event
179 date, user, rev, changed, pid, formattedmsg) 181 else:
182 src = ''
183 try:
184 ui._bbwrite('%s %s @%s%s (%s)%s> %s',
185 date, user, rev, changed, pid, src, formattedmsg)
180 except IOError as err: 186 except IOError as err:
181 self.debug('warning: cannot write to blackbox.log: %s\n' % 187 self.debug('warning: cannot write to blackbox.log: %s\n' %
182 err.strerror) 188 err.strerror)
183 if not lastui or ui._bbrepo: 189 if not lastui or ui._bbrepo:
184 lastui = ui 190 lastui = ui