ui: pass in formatted message to logger.log()
This makes sure that all logger instances will handle the message arguments
properly.
--- a/hgext/blackbox.py Sun Nov 11 17:34:46 2018 +0900
+++ b/hgext/blackbox.py Sun Nov 11 19:35:33 2018 +0900
@@ -160,7 +160,6 @@
date = dateutil.datestr(default, ui.config('blackbox', 'date-format'))
user = procutil.getuser()
pid = '%d' % procutil.getpid()
- formattedmsg = msg[0] % msg[1:]
rev = '(unknown)'
changed = ''
ctx = self._repo[None]
@@ -175,7 +174,7 @@
src = ''
try:
fmt = '%s %s @%s%s (%s)%s> %s'
- args = (date, user, rev, changed, pid, src, formattedmsg)
+ args = (date, user, rev, changed, pid, src, msg)
with _openlogfile(ui, self._bbvfs) as fp:
fp.write(fmt % args)
except (IOError, OSError) as err:
--- a/hgext/logtoprocess.py Sun Nov 11 17:34:46 2018 +0900
+++ b/hgext/logtoprocess.py Sun Nov 11 19:35:33 2018 +0900
@@ -66,7 +66,7 @@
env = {
b'EVENT': event,
b'HGPID': os.getpid(),
- b'MSG1': msg[0] % msg[1:],
+ b'MSG1': msg,
}
# keyword arguments get prefixed with OPT_ and uppercased
env.update((b'OPT_%s' % key.upper(), value)
--- a/mercurial/ui.py Sun Nov 11 17:34:46 2018 +0900
+++ b/mercurial/ui.py Sun Nov 11 19:35:33 2018 +0900
@@ -1724,14 +1724,14 @@
"""
self._loggers[name] = logger
- def log(self, event, *msg, **opts):
+ def log(self, event, msgfmt, *msgargs, **opts):
'''hook for logging facility extensions
event should be a readily-identifiable subsystem, which will
allow filtering.
- *msg should be a newline-terminated format string to log, and
- then any values to %-format into that format string.
+ msgfmt should be a newline-terminated format string to log, and
+ *msgargs are %-formatted into it.
**opts currently has no defined meanings.
'''
@@ -1741,6 +1741,7 @@
if l.tracked(event)]
if not activeloggers:
return
+ msg = msgfmt % msgargs
# guard against recursion from e.g. ui.debug()
registeredloggers = self._loggers
self._loggers = {}