1722 More than one loggers can be registered. Use extension or module |
1722 More than one loggers can be registered. Use extension or module |
1723 name to uniquely identify the logger instance. |
1723 name to uniquely identify the logger instance. |
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 ''' |
1738 if not self._loggers: |
1738 if not self._loggers: |
1739 return |
1739 return |
1740 activeloggers = [l for l in self._loggers.itervalues() |
1740 activeloggers = [l for l in self._loggers.itervalues() |
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 = {} |
1747 try: |
1748 try: |
1748 for logger in activeloggers: |
1749 for logger in activeloggers: |