24 lines
663 B
Python
24 lines
663 B
Python
"""Definition of setup_logging function."""
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
import os
|
|
|
|
|
|
def setup_logging() -> None:
|
|
"""Setup logging."""
|
|
requested_log_level = os.getenv('LOG_LEVEL', default='info')
|
|
level = getattr(logging, requested_log_level.upper())
|
|
fmt = (
|
|
'%(asctime)s | '
|
|
'%(levelname)s | '
|
|
'%(name)s | '
|
|
'%(funcName)s | '
|
|
'%(message)s'
|
|
)
|
|
datefmt = '%Y-%m-%d %H:%M:%S'
|
|
logging.basicConfig(format=fmt, datefmt=datefmt, level=level)
|
|
# change levels for modules that spam the log
|
|
logging.getLogger('pymongo').setLevel(logging.WARNING)
|
|
logging.debug('finished')
|