##// END OF EJS Templates
ui: pass in formatted message to logger.log()...
Yuya Nishihara -
r40793:ffd574c1 default
parent child Browse files
Show More
@@ -160,7 +160,6 b' class blackboxlogger(object):'
160 date = dateutil.datestr(default, ui.config('blackbox', 'date-format'))
160 date = dateutil.datestr(default, ui.config('blackbox', 'date-format'))
161 user = procutil.getuser()
161 user = procutil.getuser()
162 pid = '%d' % procutil.getpid()
162 pid = '%d' % procutil.getpid()
163 formattedmsg = msg[0] % msg[1:]
164 rev = '(unknown)'
163 rev = '(unknown)'
165 changed = ''
164 changed = ''
166 ctx = self._repo[None]
165 ctx = self._repo[None]
@@ -175,7 +174,7 b' class blackboxlogger(object):'
175 src = ''
174 src = ''
176 try:
175 try:
177 fmt = '%s %s @%s%s (%s)%s> %s'
176 fmt = '%s %s @%s%s (%s)%s> %s'
178 args = (date, user, rev, changed, pid, src, formattedmsg)
177 args = (date, user, rev, changed, pid, src, msg)
179 with _openlogfile(ui, self._bbvfs) as fp:
178 with _openlogfile(ui, self._bbvfs) as fp:
180 fp.write(fmt % args)
179 fp.write(fmt % args)
181 except (IOError, OSError) as err:
180 except (IOError, OSError) as err:
@@ -66,7 +66,7 b' class processlogger(object):'
66 env = {
66 env = {
67 b'EVENT': event,
67 b'EVENT': event,
68 b'HGPID': os.getpid(),
68 b'HGPID': os.getpid(),
69 b'MSG1': msg[0] % msg[1:],
69 b'MSG1': msg,
70 }
70 }
71 # keyword arguments get prefixed with OPT_ and uppercased
71 # keyword arguments get prefixed with OPT_ and uppercased
72 env.update((b'OPT_%s' % key.upper(), value)
72 env.update((b'OPT_%s' % key.upper(), value)
@@ -1724,14 +1724,14 b' class ui(object):'
1724 """
1724 """
1725 self._loggers[name] = logger
1725 self._loggers[name] = logger
1726
1726
1727 def log(self, event, *msg, **opts):
1727 def log(self, event, msgfmt, *msgargs, **opts):
1728 '''hook for logging facility extensions
1728 '''hook for logging facility extensions
1729
1729
1730 event should be a readily-identifiable subsystem, which will
1730 event should be a readily-identifiable subsystem, which will
1731 allow filtering.
1731 allow filtering.
1732
1732
1733 *msg should be a newline-terminated format string to log, and
1733 msgfmt should be a newline-terminated format string to log, and
1734 then any values to %-format into that format string.
1734 *msgargs are %-formatted into it.
1735
1735
1736 **opts currently has no defined meanings.
1736 **opts currently has no defined meanings.
1737 '''
1737 '''
@@ -1741,6 +1741,7 b' class ui(object):'
1741 if l.tracked(event)]
1741 if l.tracked(event)]
1742 if not activeloggers:
1742 if not activeloggers:
1743 return
1743 return
1744 msg = msgfmt % msgargs
1744 # guard against recursion from e.g. ui.debug()
1745 # guard against recursion from e.g. ui.debug()
1745 registeredloggers = self._loggers
1746 registeredloggers = self._loggers
1746 self._loggers = {}
1747 self._loggers = {}
General Comments 0
You need to be logged in to leave comments. Login now