Logging cleaned up

This sets the date format, and hase the log level, and log file as
variables.
This commit is contained in:
Jigme Datse Yli-Rasku 2024-05-29 22:46:44 -07:00
parent 4f0441ae9d
commit 86b7b61fb1
2 changed files with 13 additions and 4 deletions

View File

@ -19,4 +19,9 @@ This is our current version trying to communicate between courier and mailman3.
* This is not working * This is not working
* Reverting to previous formatting * 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. * Let's try again.
* OK, basicSettings all set at once.
* This sorts it, now let's get a date format working
* Now let's see if this works...
* Date format set:
* Level and File set in variable

View File

@ -14,9 +14,13 @@
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
FORMAT = '%(asctime)s %(clientip)-15s %(user)-8s %(message)s' # Format time and message
DATEFMT = '%Y-$M-$d %H:%m:%S' FORMAT = '%(asctime)s %(message)s'
logging.basicConfig(filename='/opt/mailman/logs/courier-to-mailman.log', level=logging.INFO, format=FORMAT) # Set Date Format
DATEFMT = '%Y-$m-$d %H:%M:%S %Z'
LEVEL=logging.INFO
LOGFILE='/opt/mailman/logs/courier-to-mailman.log'
logging.basicConfig(filename=LOGFILE, level=LEVEL, format=FORMAT, datefmt=DATEFMT)
logger.info('format set to: %s', FORMAT) logger.info('format set to: %s', FORMAT)
print('format set to: %s', FORMAT) print('format set to: %s', FORMAT)