diff --git a/docs/courier-to-mailman3.md b/docs/courier-to-mailman3.md index 50da5ad..663eaba 100644 --- a/docs/courier-to-mailman3.md +++ b/docs/courier-to-mailman3.md @@ -10,4 +10,5 @@ This is our current version trying to communicate between courier and mailman3. * Second change is to have the `#!` path hopefully pointing in the right place. * Which I screwed up. I think I was typing in the wrong window. * It's not failing on command line. -* Still failing, let's get some logging. \ No newline at end of file +* Still failing, let's get some logging. + * Moved logging initialization, and included print statements \ No newline at end of file diff --git a/source/courier-to-mailman3.py b/source/courier-to-mailman3.py index a436577..9e7cfdb 100644 --- a/source/courier-to-mailman3.py +++ b/source/courier-to-mailman3.py @@ -11,20 +11,24 @@ # $3 LMTP Host # std_in message text +import logging +logger = logging.getLogger(__name__) + +logging.basicConfig(filename='/opt/mailman/logs/courier-to-mailman.log', level=logging.INFO) + +FORMAT = '%(asctime)s %(clientip)-15s %(user)-8s %(message)s' +logging.basicConfig(format=FORMAT) + +logger.info('Starting Logging (outside try)') +print('Starting Logging (outside try)') + try: - import logging import os import sys import smtplib - logger = logging.getLogger(__name__) - - logging.basicConfig(filename='~/logs/courier-to-mailman.log', level=logging.INFO) - - FORMAT = '%(asctime)s %(clientip)-15s %(user)-8s %(message)s' - logging.basicConfig(format=FORMAT) - - logger.info('Starting Logging') + logger.info('Starting Logging (inside try)') + print('Starting Logging (inside try)') # Setup LTMP connection lmtp_host = sys.argv[3] if len(sys.argv) > 3 else 'localhost'