Set all basic settings at the same time.

Let's see if this works.
This commit is contained in:
Jigme Datse Yli-Rasku 2024-05-29 22:33:39 -07:00
parent 98ba217d03
commit 0ae1a78050
1 changed files with 4 additions and 12 deletions

View File

@ -14,23 +14,15 @@
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
## 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' 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)
formatter = logging.Formatter(FORMAT) formatter = logging.Formatter(FORMAT)
fh.setFormatter(formatter) fh.setFormatter(formatter)
ch.setFormatter(formatter) ch.setFormatter(formatter)
logger..addHandler(fh) logger.addHandler(fh)
logger.addHandler(ch) logger.addHandler(ch)
logger.info('format set to: %s', FORMAT) logger.info('format set to: %s', FORMAT)