summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorLiutauras Adomaitis <adomaitis@kolabsystems.com>2019-08-16 13:56:23 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2019-08-16 13:56:23 +0200
commit775aa79262cace87c2443475c11abb9e5b609fe4 (patch)
tree86be8e4251e9855abb22ae00f7ccf8446d0ec9cb /pykolab
parent88a6fa3f29f9bd937186f9dceb8d880b8af7692b (diff)
downloadpykolab-775aa79262cace87c2443475c11abb9e5b609fe4.tar.gz
More logging in Wallace and --max-tasks per process option for wallaced
Summary: Given that part of https://git.kolab.org/D761 changes are obsolete after commit baeee0049f06430801a2d9940f875747e51be7f5 I still want to have some changes find their way in master. Test Plan: None Reviewers: vanmeeuwen Subscribers: petersen, machniak, vanmeeuwen Differential Revision: https://git.kolab.org/D791
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/logger.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/pykolab/logger.py b/pykolab/logger.py
index 481c270..356734b 100644
--- a/pykolab/logger.py
+++ b/pykolab/logger.py
@@ -35,16 +35,27 @@ class StderrToLogger(object):
self.logger = logger
self.log_level = log_level
self.linebuf = ''
+ self.skip_next = False
def write(self, buf):
- # ugly patch to make smtplib debug logging records appear on one line in log file
+ # ugly patch to make smtplib and smtpd debug logging records appear on one line in log file
# smtplib uses "print>>stderr, var, var" statements for debug logging. These
# statements are splited into separate lines on separating whitespace.
+
for line in buf.rstrip().splitlines():
+ if self.skip_next:
+ self.skip_next = False
+ continue
+
if buf != '\n':
- if line.startswith('send:') or line.startswith('reply:'):
+ linestarts = line.split(':')[0]
+ if linestarts in ['send', 'reply', 'Data', 'recips', 'Peer', 'sender']:
self.linebuf = line
- return
+ elif linestarts.startswith('===>'):
+ # Do not log lines starting with ====>
+ self.linebuf = ''
+ self.skip_next = True
+ continue
else:
self.logger.log(self.log_level, '%s %s', self.linebuf, line.rstrip()[:150])
self.linebuf = ''
@@ -52,6 +63,14 @@ class StderrToLogger(object):
def flush(self):
pass
+class LoggerAdapter(logging.LoggerAdapter):
+ """
+ Custom LoggingAdapter to log Wallace mail message Queue ID
+ """
+
+ def process(self, msg, kwargs):
+ return '%s %s' % (self.extra['qid'], msg), kwargs
+
class Logger(logging.Logger):
"""
The PyKolab version of a logger.