Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
40438:5d8f291405e5 | 40439:25f1c7bd649d |
---|---|
31 # limit the size of a log file | 31 # limit the size of a log file |
32 maxsize = 1.5 MB | 32 maxsize = 1.5 MB |
33 # rotate up to N log files when the current one gets too big | 33 # rotate up to N log files when the current one gets too big |
34 maxfiles = 3 | 34 maxfiles = 3 |
35 | 35 |
36 [blackbox] | |
37 # Include nanoseconds in log entries with %f (see Python function | |
38 # datetime.datetime.strftime) | |
39 date-format = '%Y-%m-%d @ %H:%M:%S.%f' | |
40 | |
36 """ | 41 """ |
37 | 42 |
38 from __future__ import absolute_import | 43 from __future__ import absolute_import |
39 | 44 |
40 import errno | 45 import errno |
79 configitem('blackbox', 'maxfiles', | 84 configitem('blackbox', 'maxfiles', |
80 default=7, | 85 default=7, |
81 ) | 86 ) |
82 configitem('blackbox', 'track', | 87 configitem('blackbox', 'track', |
83 default=lambda: ['*'], | 88 default=lambda: ['*'], |
89 ) | |
90 configitem('blackbox', 'date-format', | |
91 default='%Y/%m/%d %H:%M:%S', | |
84 ) | 92 ) |
85 | 93 |
86 lastui = None | 94 lastui = None |
87 | 95 |
88 def _openlogfile(ui, vfs): | 96 def _openlogfile(ui, vfs): |
167 if getattr(ui, '_bbinlog', False): | 175 if getattr(ui, '_bbinlog', False): |
168 # recursion and failure guard | 176 # recursion and failure guard |
169 return | 177 return |
170 ui._bbinlog = True | 178 ui._bbinlog = True |
171 default = self.configdate('devel', 'default-date') | 179 default = self.configdate('devel', 'default-date') |
172 date = dateutil.datestr(default, '%Y/%m/%d %H:%M:%S') | 180 date = dateutil.datestr(default, |
181 ui.config('blackbox', 'date-format')) | |
173 user = procutil.getuser() | 182 user = procutil.getuser() |
174 pid = '%d' % procutil.getpid() | 183 pid = '%d' % procutil.getpid() |
175 formattedmsg = msg[0] % msg[1:] | 184 formattedmsg = msg[0] % msg[1:] |
176 rev = '(unknown)' | 185 rev = '(unknown)' |
177 changed = '' | 186 changed = '' |