Implement LoggerFactory for retrieving loggers
parent
6141e339a2
commit
0b088fab1d
@ -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…
Reference in New Issue