From f7c58d6098c9a548339633360d92dc563d993ec2 Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Fri, 6 Jul 2001 05:35:39 +0000 Subject: LogMsg() -> write() write(): Just call new function write_ex(), passing arguments through. write_ex(): Use explicit arguments to pass in the args tuple and kws dictionary. This is because Python requires **kws in extended calls to be concrete dictionary objects, not generic mapping objects. SMTPDirect wants to pass in an instance of (subclassed) UserDict, so it calls write_ex() directly. Also, stash the msg argument in local variable origmsg, which is used if we get an exception during string interpolation. --- Mailman/Logging/Syslog.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Mailman/Logging/Syslog.py') diff --git a/Mailman/Logging/Syslog.py b/Mailman/Logging/Syslog.py index 2f740ff14..1dc41fc3c 100644 --- a/Mailman/Logging/Syslog.py +++ b/Mailman/Logging/Syslog.py @@ -36,7 +36,14 @@ class _Syslog: def __del__(self): self.close() - def LogMsg(self, kind, msg, *args, **kws): + def write(self, kind, msg, *args, **kws): + self.write_ex(kind, msg, args, kws) + + # We need this because SMTPDirect tries to pass in a special dict-like + # object, which is not a concrete dictionary. This is not allowed by + # Python's extended call syntax. :( + def write_ex(self, kind, msg, args=None, kws=None): + origmsg = msg logf = self._logfiles.get(kind) if not logf: logf = self._logfiles[kind] = StampedLogger(kind) @@ -47,11 +54,11 @@ class _Syslog: msg %= kws # It's really bad if exceptions in the syslogger cause other crashes except Exception, e: - msg = 'Bad format "%s": %s' % (msg, e) + msg = 'Bad format "%s": %s: %s' % (origmsg, repr(e), e) logf.write(msg + '\n') # For the ultimate in convenience - __call__ = LogMsg + __call__ = write def close(self): for kind, logger in self._logfiles.items(): -- cgit v1.2.3-70-g09d2