Let's get this working

Or let's see if we can...  This is a far more complex version with
conslole logging, and file logging.  But hopefully it gives us
formatting.
This commit is contained in:
Jigme Datse Yli-Rasku 2024-05-29 22:23:51 -07:00
parent 7baad18daf
commit 98ba217d03
2 changed files with 16 additions and 3 deletions

View File

@ -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 idea what steps we've gone through to get here.
* Let's try again.

View File

@ -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)