2023-07-09 18:52:12 +02:00

32 lines
846 B
Python

import logging
LOGGER = logging.getLogger(__package__)
def set_logging_config(app_log_level: int, root_log_level: int):
"""
Sets Application logging defaults
Differentiates between Application Log Level and root Log Level
"""
logging.basicConfig(
level=root_log_level,
format='%(asctime)s %(levelname)-8s %(message)s ',
datefmt='%Y-%m-%dT%H:%M:%SZ',
force=True
)
# configure individual logger for application
LOGGER.setLevel(app_log_level)
LOGGER.propagate = False
console_handler = logging.StreamHandler()
console_handler.setLevel(app_log_level)
console_handler.setFormatter(
logging.Formatter(
fmt='%(asctime)s %(levelname)-8s %(message)s ',
datefmt='%Y-%m-%dT%H:%M:%SZ'
)
)
LOGGER.addHandler(console_handler)