diff --git a/docs/courier-to-mailman3.md b/docs/courier-to-mailman3.md index 3755635..f1859d3 100644 --- a/docs/courier-to-mailman3.md +++ b/docs/courier-to-mailman3.md @@ -18,4 +18,5 @@ This is our current version trying to communicate between courier and mailman3. * Nope used `Format` not `Formater`. * This is not working * Reverting to previous formatting -* No idea what steps we've gone through to get here. \ No newline at end of file +* No idea what steps we've gone through to get here. +* Let's try again. \ No newline at end of file diff --git a/source/courier-to-mailman3.py b/source/courier-to-mailman3.py index 2008b26..308c9c6 100644 --- a/source/courier-to-mailman3.py +++ b/source/courier-to-mailman3.py @@ -14,12 +14,24 @@ import logging logger = logging.getLogger(__name__) -logging.basicConfig(filename='/opt/mailman/logs/courier-to-mailman.log', level=logging.INFO) +## Changing how to handle this: +#logging.basicConfig(filename='/opt/mailman/logs/courier-to-mailman.log', level=logging.INFO) + +# File Logging +fh = logging.FileHandler(/opt/mailman/logs/courier-to-mailman.log') +fh.setLevel(logging.DEBUG) + +# Console Logging +ch = logging.StreamHandler() +ch.setLevel(logging.ERROR) FORMAT = '%(asctime)s %(clientip)-15s %(user)-8s %(message)s' formatter = logging.Formatter(FORMAT) -logger.setFormatter(formatter) +fh.setFormatter(formatter) +ch.setFormatter(formatter) +logger..addHandler(fh) +logger.addHandler(ch) logger.info('format set to: %s', FORMAT) print('format set to: %s', FORMAT)