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

@ -20,3 +20,8 @@ This is our current version trying to communicate between courier and mailman3.
* Reverting to previous formatting
* No idea what steps we've gone through to get here.
* 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
logger = logging.getLogger(__name__)
FORMAT = '%(asctime)s %(clientip)-15s %(user)-8s %(message)s'
DATEFMT = '%Y-$M-$d %H:%m:%S'
logging.basicConfig(filename='/opt/mailman/logs/courier-to-mailman.log', level=logging.INFO, format=FORMAT)
# Format time and message
FORMAT = '%(asctime)s %(message)s'
# 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)
print('format set to: %s', FORMAT)