Implement LoggerFactory for retrieving loggers

main
sgoudham 3 years ago
parent 6141e339a2
commit 0b088fab1d
Signed by: hammy
GPG Key ID: 44E818FD5457EEA4

@ -0,0 +1,19 @@
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
Loading…
Cancel
Save