diff --git a/pyquarantine/action.py b/pyquarantine/action.py index bb03f23..2ab8767 100644 --- a/pyquarantine/action.py +++ b/pyquarantine/action.py @@ -14,6 +14,7 @@ __all__ = ["Action"] +from copy import deepcopy from pyquarantine import modify, notify, storage from pyquarantine.conditions import Conditions @@ -40,7 +41,7 @@ class Action: self.conditions = Conditions(self.conditions, local_addrs, debug) self.action = self.ACTION_TYPES[cfg["type"]]( - cfg, local_addrs, debug) + deepcopy(cfg), local_addrs, debug) def __str__(self): cfg = [] diff --git a/pyquarantine/cli.py b/pyquarantine/cli.py index a40faa0..acc81a6 100644 --- a/pyquarantine/cli.py +++ b/pyquarantine/cli.py @@ -302,7 +302,7 @@ def release(cfg, args): rcpts = quarantine.release(args.quarantine_id, args.recipient) rcpts = ", ".join(rcpts) logger.info( - f"{args.quarantine}: released message with id {args.quarantine_id} " + f"{quarantine._storage.name}: released message with id {args.quarantine_id} " f"for {rcpts}") diff --git a/pyquarantine/config.py b/pyquarantine/config.py index 8b94717..2630778 100644 --- a/pyquarantine/config.py +++ b/pyquarantine/config.py @@ -36,7 +36,6 @@ import jsonschema import logging import re - class BaseConfig: JSON_SCHEMA = { "type": "object", diff --git a/pyquarantine/notify.py b/pyquarantine/notify.py index 1464c3d..107aeb6 100644 --- a/pyquarantine/notify.py +++ b/pyquarantine/notify.py @@ -317,6 +317,7 @@ class EMailNotification(BaseNotification): def execute(self, milter, logger): super().execute(milter, logger) + logger.info(f"send notification(s) to {milter.msginfo['rcpts']}") self.notify(msg=milter.msg, qid=milter.qid, mailfrom=milter.msginfo["mailfrom"], recipients=milter.msginfo["rcpts"], @@ -330,6 +331,7 @@ class Notify: def __init__(self, cfg, local_addrs, debug): self.cfg = cfg + self.name = cfg["name"] self.logger = logging.getLogger(cfg["name"]) del cfg["name"] self.logger.setLevel(cfg.get_loglevel(debug)) @@ -351,5 +353,5 @@ class Notify: def execute(self, milter): logger = CustomLogger( - self.logger, {"name": self.cfg["name"], "qid": milter.qid}) + self.logger, {"name": self.name, "qid": milter.qid}) self._notification.execute(milter, logger) diff --git a/pyquarantine/storage.py b/pyquarantine/storage.py index b5da2ec..2ee7e41 100644 --- a/pyquarantine/storage.py +++ b/pyquarantine/storage.py @@ -406,6 +406,8 @@ class Quarantine: self.logger = logging.getLogger(cfg["name"]) self.logger.setLevel(cfg.get_loglevel(debug)) + name = cfg["options"]["store"]["name"] + cfg["options"]["store"]["name"] = f"{cfg['name']}: {name}" cfg["options"]["store"]["loglevel"] = cfg["loglevel"] self._storage = Store(cfg["options"]["store"], local_addrs, debug) @@ -414,6 +416,8 @@ class Quarantine: self._notification = None if "notify" in cfg["options"]: + name = cfg["options"]["notify"]["name"] + cfg["options"]["notify"]["name"] = f"{cfg['name']}: {name}" cfg["options"]["notify"]["loglevel"] = cfg["loglevel"] self._notification = Notify( cfg["options"]["notify"], local_addrs, debug) @@ -559,6 +563,8 @@ class Quarantine: if self._milter_action in ["REJECT", "DISCARD"]: logger.info(f"quarantine message for {rcpts}") + else: + logger.info(f"save message for {rcpts}") self._storage.execute(milter)