From 750eb6716d7cc603ae877a484a02bc1b420eb2c5 Mon Sep 17 00:00:00 2001 From: J08nY Date: Tue, 27 Jun 2017 17:53:02 +0200 Subject: Add logging to `mailman.plugin.pgp`. --- src/mailman_pgp/runners/incoming.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/mailman_pgp/runners') diff --git a/src/mailman_pgp/runners/incoming.py b/src/mailman_pgp/runners/incoming.py index 7bc14e1..2941502 100644 --- a/src/mailman_pgp/runners/incoming.py +++ b/src/mailman_pgp/runners/incoming.py @@ -16,6 +16,7 @@ # this program. If not, see . """The encryption-aware incoming runner.""" +import logging from mailman.config import config as mailman_config from mailman.core.runner import Runner @@ -28,6 +29,8 @@ from mailman_pgp.config import config from mailman_pgp.model.list import PGPMailingList from mailman_pgp.pgp.wrapper import PGPWrapper +log = logging.getLogger('mailman.plugin.pgp') + def _pass_default(msg, msgdata, listid): inq = config.get('queues', 'in') @@ -42,7 +45,7 @@ class IncomingRunner(Runner): # Is the message for an encrypted mailing list? If not, pass to default # incoming runner. If yes, go on. pgp_list = PGPMailingList.query().filter_by( - list_id=mlist.list_id).first() + list_id=mlist.list_id).first() if not pgp_list: _pass_default(msg, msgdata, mlist.list_id) return False @@ -61,9 +64,12 @@ class IncomingRunner(Runner): # jump to the moderation chain if `pgp_moderate` is True action = pgp_list.nonencrypted_msg_action if action != Action.defer: - msgdata['moderation_action'] = action + reason = 'Message was not encrypted.' + log.info('[pgp] {}{}: {}'.format( + action.name, msg.get('message-id', 'n/a'), reason)) + msgdata['moderation_action'] = action.name msgdata['moderation_sender'] = msg.sender - msgdata['moderation_reason'] = 'Message was not encrypted.' + msgdata['moderation_reason'] = reason msgdata['pgp_moderate'] = True _pass_default(msg, msgdata, mlist.list_id) -- cgit v1.2.3-70-g09d2