Mercurial > public > mercurial-scm > hg
comparison mercurial/ui.py @ 45025:24b1a8eb73aa
ui: add option to timestamp status and diagnostic messages
Differential Revision: https://phab.mercurial-scm.org/D8640
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Thu, 18 Jun 2020 15:13:38 +0200 |
parents | 484e04dc7f42 |
children | b4b6ff83ed9c |
comparison
equal
deleted
inserted
replaced
45019:4a503c1b664a | 45025:24b1a8eb73aa |
---|---|
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import collections | 10 import collections |
11 import contextlib | 11 import contextlib |
12 import datetime | |
12 import errno | 13 import errno |
13 import getpass | 14 import getpass |
14 import inspect | 15 import inspect |
15 import os | 16 import os |
16 import re | 17 import re |
240 # color mode: see mercurial/color.py for possible value | 241 # color mode: see mercurial/color.py for possible value |
241 self._colormode = None | 242 self._colormode = None |
242 self._terminfoparams = {} | 243 self._terminfoparams = {} |
243 self._styles = {} | 244 self._styles = {} |
244 self._uninterruptible = False | 245 self._uninterruptible = False |
246 self.showtimestamp = False | |
245 | 247 |
246 if src: | 248 if src: |
247 self._fout = src._fout | 249 self._fout = src._fout |
248 self._ferr = src._ferr | 250 self._ferr = src._ferr |
249 self._fin = src._fin | 251 self._fin = src._fin |
559 if self.verbose and self.quiet: | 561 if self.verbose and self.quiet: |
560 self.quiet = self.verbose = False | 562 self.quiet = self.verbose = False |
561 self._reportuntrusted = self.debugflag or self.configbool( | 563 self._reportuntrusted = self.debugflag or self.configbool( |
562 b"ui", b"report_untrusted" | 564 b"ui", b"report_untrusted" |
563 ) | 565 ) |
566 self.showtimestamp = self.configbool(b'ui', b'timestamp-output') | |
564 self.tracebackflag = self.configbool(b'ui', b'traceback') | 567 self.tracebackflag = self.configbool(b'ui', b'traceback') |
565 self.logblockedtimes = self.configbool(b'ui', b'logblockedtimes') | 568 self.logblockedtimes = self.configbool(b'ui', b'logblockedtimes') |
566 | 569 |
567 if section in (None, b'trusted'): | 570 if section in (None, b'trusted'): |
568 # update trust information | 571 # update trust information |
1215 self._blockedtimes[b'stdio_blocked'] += ( | 1218 self._blockedtimes[b'stdio_blocked'] += ( |
1216 util.timer() - starttime | 1219 util.timer() - starttime |
1217 ) * 1000 | 1220 ) * 1000 |
1218 | 1221 |
1219 def _writemsg(self, dest, *args, **opts): | 1222 def _writemsg(self, dest, *args, **opts): |
1223 timestamp = self.showtimestamp and opts.get('type') in { | |
1224 b'debug', | |
1225 b'error', | |
1226 b'note', | |
1227 b'status', | |
1228 b'warning', | |
1229 } | |
1230 if timestamp: | |
1231 args = ( | |
1232 b'[%s] ' % bytes(datetime.datetime.now().isoformat(), 'ASCII'), | |
1233 ) + args | |
1220 _writemsgwith(self._write, dest, *args, **opts) | 1234 _writemsgwith(self._write, dest, *args, **opts) |
1235 if timestamp: | |
1236 dest.flush() | |
1221 | 1237 |
1222 def _writemsgnobuf(self, dest, *args, **opts): | 1238 def _writemsgnobuf(self, dest, *args, **opts): |
1223 _writemsgwith(self._writenobuf, dest, *args, **opts) | 1239 _writemsgwith(self._writenobuf, dest, *args, **opts) |
1224 | 1240 |
1225 def flush(self): | 1241 def flush(self): |