cronpy/core/log.py

16 lines
441 B
Python
Raw Normal View History

2020-10-03 21:17:53 +00:00
import logging.handlers
import sys
import setting
def get_logger(name, level=setting.LOG_LEVEL):
logger = logging.getLogger(name)
formatter = logging.Formatter('[%(asctime)s] %(levelname)s / %(name)s : %(message)s')
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
handler.setFormatter(formatter)
logger.setLevel(getattr(logging, level))
logger.addHandler(handler)
return logger