로그 출력 기능
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
# common.py
|
# common.py
|
||||||
import os, yaml
|
import os, yaml
|
||||||
|
import logging
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
"""
|
"""
|
||||||
@ -8,3 +9,13 @@ def load_config():
|
|||||||
path = os.path.join(os.path.dirname(__file__), '..', 'conf', 'config.yaml')
|
path = os.path.join(os.path.dirname(__file__), '..', 'conf', 'config.yaml')
|
||||||
with open(path, encoding='utf-8') as f:
|
with open(path, encoding='utf-8') as f:
|
||||||
return yaml.safe_load(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
|
||||||
|
|||||||
Reference in New Issue
Block a user