summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2001-06-27 17:33:57 +0000
committerbwarsaw2001-06-27 17:33:57 +0000
commitb3cbd28da9c8f4bf7ad44af51b28172f424997d9 (patch)
treeb37bb8ec9e209589db98f353240de38fbc1e1d36
parent724e919d72ca0a227c96d37bf82d3df58e066114 (diff)
downloadmailman-b3cbd28da9c8f4bf7ad44af51b28172f424997d9.tar.gz
mailman-b3cbd28da9c8f4bf7ad44af51b28172f424997d9.tar.zst
mailman-b3cbd28da9c8f4bf7ad44af51b28172f424997d9.zip
LogMsg(): Extended function signature to make argument passing both
nicer and more robust. String interpolation is now done here instead of at callee site, so exceptions like TypeError and ValueError can be caught and dealt with better.
-rw-r--r--Mailman/Logging/Syslog.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/Mailman/Logging/Syslog.py b/Mailman/Logging/Syslog.py
index 04ca54598..2f740ff14 100644
--- a/Mailman/Logging/Syslog.py
+++ b/Mailman/Logging/Syslog.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998,1999,2000 by the Free Software Foundation, Inc.
+# Copyright (C) 1998,1999,2000,2001 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -19,7 +19,8 @@
This might eventually be replaced by a syslog based logger, hence the name.
"""
-from StampedLogger import StampedLogger
+from Mailman.Logging.StampedLogger import StampedLogger
+
# Global, shared logger instance. All clients should use this object.
@@ -35,10 +36,18 @@ class _Syslog:
def __del__(self):
self.close()
- def LogMsg(self, kind, msg):
+ def LogMsg(self, kind, msg, *args, **kws):
logf = self._logfiles.get(kind)
if not logf:
logf = self._logfiles[kind] = StampedLogger(kind)
+ try:
+ if args:
+ msg %= args
+ if kws:
+ msg %= kws
+ # It's really bad if exceptions in the syslogger cause other crashes
+ except Exception, e:
+ msg = 'Bad format "%s": %s' % (msg, e)
logf.write(msg + '\n')
# For the ultimate in convenience