Mercurial > public > mercurial-scm > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/ui.py Mon Jun 29 20:53:32 2020 +0900 +++ b/mercurial/ui.py Thu Jun 18 15:13:38 2020 +0200 @@ -9,6 +9,7 @@ import collections import contextlib +import datetime import errno import getpass import inspect @@ -242,6 +243,7 @@ self._terminfoparams = {} self._styles = {} self._uninterruptible = False + self.showtimestamp = False if src: self._fout = src._fout @@ -561,6 +563,7 @@ self._reportuntrusted = self.debugflag or self.configbool( b"ui", b"report_untrusted" ) + self.showtimestamp = self.configbool(b'ui', b'timestamp-output') self.tracebackflag = self.configbool(b'ui', b'traceback') self.logblockedtimes = self.configbool(b'ui', b'logblockedtimes') @@ -1217,7 +1220,20 @@ ) * 1000 def _writemsg(self, dest, *args, **opts): + timestamp = self.showtimestamp and opts.get('type') in { + b'debug', + b'error', + b'note', + b'status', + b'warning', + } + if timestamp: + args = ( + b'[%s] ' % bytes(datetime.datetime.now().isoformat(), 'ASCII'), + ) + args _writemsgwith(self._write, dest, *args, **opts) + if timestamp: + dest.flush() def _writemsgnobuf(self, dest, *args, **opts): _writemsgwith(self._writenobuf, dest, *args, **opts)