summaryrefslogtreecommitdiff
path: root/Mailman/loginit.py
diff options
context:
space:
mode:
authorbwarsaw2006-04-24 03:55:29 +0000
committerbwarsaw2006-04-24 03:55:29 +0000
commit155748d1c28457ce49dd6f67df24cd01285438a4 (patch)
treedfa5e8ddcc0bad1a92a55a901c078d49071c3bc6 /Mailman/loginit.py
parent93ffb008e4ce9b0655499f482da9613a229f68c8 (diff)
downloadmailman-155748d1c28457ce49dd6f67df24cd01285438a4.tar.gz
mailman-155748d1c28457ce49dd6f67df24cd01285438a4.tar.zst
mailman-155748d1c28457ce49dd6f67df24cd01285438a4.zip
- Fixes to further remove the old Syslog from bin and cron scripts. Note that
I didn't update cron/mailpasswds because that is going away. cron/disabled and cron/gate_news are only minimally tested. - Instead of using the RotatingFileHandler for our logs, use our own ReopenableFileHandler, which only minimally derives from FileHandler and implements a reopen() method. I think it's generally better to leave file rotation to external tools such as logrotate. - Remove some Python 2.1 compatibility stuff. - Ignore .mo files in messages/vi/LC_MESSAGES
Diffstat (limited to 'Mailman/loginit.py')
-rw-r--r--Mailman/loginit.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/Mailman/loginit.py b/Mailman/loginit.py
index 323bd2985..a0a0699e3 100644
--- a/Mailman/loginit.py
+++ b/Mailman/loginit.py
@@ -21,8 +21,8 @@ import below. Ah, for Python 2.5 and absolute imports.
"""
import os
+import codecs
import logging
-import logging.handlers
from Mailman import mm_cfg
@@ -37,6 +37,25 @@ _handlers = []
+class ReopenableFileHandler(logging.FileHandler):
+ def __init__(self, filename, mode='a', encoding=None):
+ # Unfortunately, FileHandler's __init__() doesn't store encoding.
+ logging.FileHandler.__init__(self, filename, mode, encoding)
+ self.encoding = encoding
+
+ def reopen(self):
+ # Flush and close the file/stream, then reopen it. WIBNI the base
+ # FileHandler supported this?
+ self.flush()
+ self.stream.close()
+ if self.encoding is None:
+ stream = open(self.baseFilename, self.mode)
+ else:
+ stream = codecs.open(self.baseFilename, mode, self.encoding)
+ self.stream = stream
+
+
+
def initialize(propagate=False):
# XXX Don't call logging.basicConfig() because in Python 2.3, it adds a
# handler to the root logger that we don't want. When Python 2.4 is the
@@ -72,9 +91,7 @@ def initialize(propagate=False):
# Propagation to the root logger is how we handle logging to stderr
# when the qrunners are not run as a subprocess of mailmanctl.
log.propagate = propagate
- handler = logging.handlers.RotatingFileHandler(
- os.path.join(mm_cfg.LOG_DIR, logger),
- maxBytes=0, backupCount=0)
+ handler = ReopenableFileHandler(os.path.join(mm_cfg.LOG_DIR, logger))
_handlers.append(handler)
handler.setFormatter(formatter)
log.addHandler(handler)
@@ -83,6 +100,4 @@ def initialize(propagate=False):
def reopen():
for handler in _handlers:
- meth = getattr(handler, 'doRollover', None)
- if meth:
- meth()
+ handler.reopen()