Patchwork [3,of,6] blackbox: optionally log event source

login
register
mail settings
Submitter timeless@mozdev.org
Date March 1, 2016, 11:51 a.m.
Message ID <c30da8f7af8b18641911.1456833105@waste.org>
Download mbox | patch
Permalink /patch/13498/
State Accepted
Headers show

Comments

timeless@mozdev.org - March 1, 2016, 11:51 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1455219506 0
#      Thu Feb 11 19:38:26 2016 +0000
# Node ID c30da8f7af8b18641911c972197e69a2a2aa46d8
# Parent  e19277557090548ed21a72c7984e24e5c25e4669
blackbox: optionally log event source
Augie Fackler - March 1, 2016, 6:40 p.m.
On Tue, Mar 01, 2016 at 05:51:45AM -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1455219506 0
> #      Thu Feb 11 19:38:26 2016 +0000
> # Node ID c30da8f7af8b18641911c972197e69a2a2aa46d8
> # Parent  e19277557090548ed21a72c7984e24e5c25e4669
> blackbox: optionally log event source

I've taken the first three patches, but I'm not entirely sure the last
three feel right. I'll let someone else look at those.

>
> diff --git a/hgext/blackbox.py b/hgext/blackbox.py
> --- a/hgext/blackbox.py
> +++ b/hgext/blackbox.py
> @@ -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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -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)