comparison hgext/blackbox.py @ 50993:12c308c55e53

branching: merge stable into default
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 11 Oct 2023 02:02:46 +0200
parents 7f8f6fe13fa9 4323af38e3f2
children f4733654f144
comparison
equal deleted inserted replaced
50989:752c5a5b73c6 50993:12c308c55e53
97 self._inlog = False 97 self._inlog = False
98 98
99 def _log(self, ui, event, msg, opts): 99 def _log(self, ui, event, msg, opts):
100 default = ui.configdate(b'devel', b'default-date') 100 default = ui.configdate(b'devel', b'default-date')
101 dateformat = ui.config(b'blackbox', b'date-format') 101 dateformat = ui.config(b'blackbox', b'date-format')
102 debug_to_stderr = ui.configbool(b'blackbox', b'debug.to-stderr')
102 if dateformat: 103 if dateformat:
103 date = dateutil.datestr(default, dateformat) 104 date = dateutil.datestr(default, dateformat)
104 else: 105 else:
105 # We want to display milliseconds (more precision seems 106 # We want to display milliseconds (more precision seems
106 # unnecessary). Since %.3f is not supported, use %f and truncate 107 # unnecessary). Since %.3f is not supported, use %f and truncate
128 self._repo.vfs, 129 self._repo.vfs,
129 name=b'blackbox.log', 130 name=b'blackbox.log',
130 maxfiles=self._maxfiles, 131 maxfiles=self._maxfiles,
131 maxsize=self._maxsize, 132 maxsize=self._maxsize,
132 ) as fp: 133 ) as fp:
133 fp.write(fmt % args) 134 msg = fmt % args
135 fp.write(msg)
136 if debug_to_stderr:
137 ui.write_err(msg)
134 except (IOError, OSError) as err: 138 except (IOError, OSError) as err:
135 # deactivate this to avoid failed logging again 139 # deactivate this to avoid failed logging again
136 self._trackedevents.clear() 140 self._trackedevents.clear()
137 ui.debug( 141 ui.debug(
138 b'warning: cannot write to blackbox.log: %s\n' 142 b'warning: cannot write to blackbox.log: %s\n'