From: Frank Brehm Date: Thu, 11 Apr 2024 15:22:43 +0000 (+0200) Subject: Changing logging output. X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=be1ae59d5dc37aec64f579cfd74156d0fc5d1c60;p=pixelpark%2Fpp-admin-tools.git Changing logging output. --- diff --git a/lib/pp_admintools/app/get_from_addr.py b/lib/pp_admintools/app/get_from_addr.py index c15f279..a98ce8d 100644 --- a/lib/pp_admintools/app/get_from_addr.py +++ b/lib/pp_admintools/app/get_from_addr.py @@ -22,7 +22,7 @@ from . import BaseDPXApplication from ..handler.pflogparse import PostfixLogfileParser from ..xlate import XLATOR -__version__ = '0.3.0' +__version__ = '0.3.1' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -57,6 +57,7 @@ class GetFromAddressesApp(BaseDPXApplication): # ------------------------------------------------------------------------- def __init__(self, appname=None, base_dir=None): """Initialize the SetLdapPasswordApplication object.""" + PostfixLogfileParser.warn_on_parse_error = False self.pflogparser = PostfixLogfileParser( appname=appname, base_dir=base_dir, initialized=True) diff --git a/lib/pp_admintools/handler/pflogparse.py b/lib/pp_admintools/handler/pflogparse.py index d81fdf1..c6761a9 100644 --- a/lib/pp_admintools/handler/pflogparse.py +++ b/lib/pp_admintools/handler/pflogparse.py @@ -34,7 +34,7 @@ LOG = logging.getLogger(__name__) _ = XLATOR.gettext ngettext = XLATOR.ngettext -__version__ = '0.6.0' +__version__ = '0.6.1' # ============================================================================= @@ -80,7 +80,7 @@ class PostfixLogfileParser(HandlingObject): re_pickup = re.compile(r'uid=(?P\d+)\s+from=<(?P[^>]*)>', re.IGNORECASE) - warn_on_parse_error = True + warn_on_parse_error = False deliver_commands = ( 'postfix/discard', 'postfix/error', 'postfix/local', @@ -108,9 +108,9 @@ class PostfixLogfileParser(HandlingObject): terminal_has_colors=terminal_has_colors, initialized=False, ) - if not self.warn_on_parse_error: - DeliverAction.warn_on_parse_error = False - PostfixLogchainInfo.warn_on_parse_error = False + if self.warn_on_parse_error: + DeliverAction.warn_on_parse_error = True + PostfixLogchainInfo.warn_on_parse_error = True self.reset(no_warnings=True) @@ -185,7 +185,7 @@ class PostfixLogfileParser(HandlingObject): LOG.debug(_('Reading file {!r} as an uncompressed file.').format(str(logfile))) fh = logfile.open('rt', **self.open_args) -# self,parse(fh) + self.parse(fh) finally: if fh: @@ -417,11 +417,9 @@ class PostfixLogfileParser(HandlingObject): self, command, postfix_id, timestamp=None, host=None, pid=None, message=None): """Evaluate a postfix/smtp action log line.""" if postfix_id not in self.chain: - msg = _('Postfix transaction {!r} does not exists.').format(postfix_id) - if self.warn_on_parse_error: + msg = _('Postfix transaction {!r} for delivering does not exists.').format(postfix_id) + if self.warn_on_parse_error or self.verbose > 1: LOG.warn(msg) - else: - LOG.debug(msg) return action = DeliverAction.from_log_entry( @@ -456,10 +454,8 @@ class PostfixLogfileParser(HandlingObject): msg = _('Did not found Postfix ID {pfid!r} for Message Id {mid!r}.').format( pfid=postfix_id, mid=m[1]) - if self.warn_on_parse_error: + if self.warn_on_parse_error or self.verbose > 1: LOG.warn(msg) - else: - LOG.debug(msg) return True @@ -500,10 +496,8 @@ class PostfixLogfileParser(HandlingObject): msg = _('Did not found Postfix ID {pfid!r} for OpenDKIM log entry.').format( pfid=postfix_id) - if self.warn_on_parse_error: + if self.warn_on_parse_error or self.verbose > 1: LOG.warn(msg) - else: - LOG.debug(msg) return True @@ -524,10 +518,8 @@ class PostfixLogfileParser(HandlingObject): msg = _('Did not found Postfix ID {pfid!r} for Bounce ID {bid!r}.').format( pfid=postfix_id, bid=bid) - if self.warn_on_parse_error: + if self.warn_on_parse_error or self.verbose > 1: LOG.warn(msg) - else: - LOG.debug(msg) return True diff --git a/lib/pp_admintools/postfix_chain.py b/lib/pp_admintools/postfix_chain.py index a9b1196..afd07ab 100644 --- a/lib/pp_admintools/postfix_chain.py +++ b/lib/pp_admintools/postfix_chain.py @@ -41,7 +41,7 @@ except ImportError: _ = XLATOR.gettext ngettext = XLATOR.ngettext -__version__ = '0.8.2' +__version__ = '0.8.3' LOG = logging.getLogger(__name__) @@ -217,7 +217,7 @@ class DataPair(object): class DeliverAction(FbGenericBaseObject): """A class encapsulating the logged action of a Postix deliverer.""" - warn_on_parse_error = True + warn_on_parse_error = False attributes = ( 'command', 'to_address', 'origin_to', 'pid', 'date', 'relay', 'delay_total', @@ -825,7 +825,7 @@ class DeliverAction(FbGenericBaseObject): class PostfixLogchainInfo(FbGenericBaseObject): """A class for encapsulating the information from a chain of Postfix log entries.""" - warn_on_parse_error = True + warn_on_parse_error = False attributes = ( 'client_host', 'client_addr', 'start', 'end', 'message_id', 'postfix_id', 'ehlo',