You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
exclamation-mark-charity/exclamation_mark_charity/logger_factory.py

20 lines
605 B
Python

import logging
from exclamation_mark_charity.constants import LOG_FILE
class LoggerFactory:
def __init__(self):
pass
@staticmethod
def get_logger(name: str) -> logging.Logger:
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename=LOG_FILE, encoding="utf-8", mode="a")
handler.setFormatter(
logging.Formatter("[%(asctime)s] [%(levelname)8s] -> %(message)s (%(name)s:%(lineno)s)",
"%Y-%m-%d %H:%M:%S"))
logger.addHandler(handler)
return logger