Mercurial > public > mercurial-scm > hg
diff hgext/blackbox.py @ 40439:25f1c7bd649d
blackbox: add configitem for format of log timestamps
Sometimes blackbox logs are used to report performance problems, but the
timestamps are only at second granularity, so often the timings have to
stated separately by the reporter. This is inconvenient and error-prone,
so I would like to include %f in the date format. This patch makes that
possible.
author | Matt DeVore <matvore@google.com> |
---|---|
date | Wed, 17 Oct 2018 15:48:01 -0700 |
parents | fa88170c10bb |
children | 5bd3d6b264c1 |
line wrap: on
line diff
--- a/hgext/blackbox.py Tue Oct 23 14:04:17 2018 -0700 +++ b/hgext/blackbox.py Wed Oct 17 15:48:01 2018 -0700 @@ -33,6 +33,11 @@ # rotate up to N log files when the current one gets too big maxfiles = 3 + [blackbox] + # Include nanoseconds in log entries with %f (see Python function + # datetime.datetime.strftime) + date-format = '%Y-%m-%d @ %H:%M:%S.%f' + """ from __future__ import absolute_import @@ -82,6 +87,9 @@ configitem('blackbox', 'track', default=lambda: ['*'], ) +configitem('blackbox', 'date-format', + default='%Y/%m/%d %H:%M:%S', +) lastui = None @@ -169,7 +177,8 @@ return ui._bbinlog = True default = self.configdate('devel', 'default-date') - date = dateutil.datestr(default, '%Y/%m/%d %H:%M:%S') + date = dateutil.datestr(default, + ui.config('blackbox', 'date-format')) user = procutil.getuser() pid = '%d' % procutil.getpid() formattedmsg = msg[0] % msg[1:]