Skip to content
Snippets Groups Projects
Commit ff34a915 authored by ale's avatar ale
Browse files

Send all logs to syslog

With facility=MAIL.
parent f7b7356d
No related branches found
No related tags found
No related merge requests found
......@@ -21,8 +21,7 @@ This might eventually be replaced by a syslog based logger, hence the name.
"""
import quopri
from Mailman.Logging.StampedLogger import StampedLogger
import syslog as real_syslog
......@@ -30,6 +29,28 @@ from Mailman.Logging.StampedLogger import StampedLogger
syslog = None
# Our syslog-writing class
_syslog_initialized = False
class _SyslogLogger(Logger):
def __init__(self, kind):
global _syslog_initialized
if not _syslog_initialized:
real_syslog.openlog(
identity='mailman',
facility=real_syslog.LOG_MAIL)
_syslog_initialized = True
self._priority = real_syslog.LOG_INFO
if kind == 'error' or kind == 'smtp-failure':
self._priority = real_syslog.LOG_ERROR
def write(self, msg):
real_syslog.syslog(self._priority, msg)
def close(self):
pass
# Don't instantiate except below.
class _Syslog:
......@@ -49,7 +70,7 @@ class _Syslog:
origmsg = msg
logf = self._logfiles.get(kind)
if not logf:
logf = self._logfiles[kind] = StampedLogger(kind)
logf = self._logfiles[kind] = _SyslogLogger(kind)
try:
if args:
msg %= args
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment