22 lines
651 B
Python
22 lines
651 B
Python
# common.py
|
|
import os, yaml
|
|
import logging
|
|
|
|
def load_config():
|
|
"""
|
|
conf/config.yaml 파일을 UTF-8로 읽어 파이썬 dict로 반환
|
|
"""
|
|
path = os.path.join(os.path.dirname(__file__), '..', 'conf', 'config.yaml')
|
|
with open(path, encoding='utf-8') as f:
|
|
return yaml.safe_load(f)
|
|
|
|
def get_logger(name):
|
|
logger = logging.getLogger(name)
|
|
if not logger.handlers:
|
|
handler = logging.StreamHandler()
|
|
formatter = logging.Formatter('[%(asctime)s] %(levelname)s: %(message)s')
|
|
handler.setFormatter(formatter)
|
|
logger.addHandler(handler)
|
|
logger.setLevel(logging.INFO)
|
|
return logger
|