This commit is contained in:
0Xiao0
2025-02-06 10:39:47 +08:00
parent 6ed4d1b2e3
commit 7faa37e22c

View File

@ -14,10 +14,7 @@ class Main():
def init_log_handlers(self): def init_log_handlers(self):
with open(".env.yaml", "r") as file: with open(".env.yaml", "r") as file:
config = yaml.safe_load(file) config = yaml.safe_load(file)
if config["log"] is None: try:
return
if config["log"]["handlers"] is None:
return
log_handler_confg = config["log"]["handlers"] log_handler_confg = config["log"]["handlers"]
log_handlers = [logging.StreamHandler()] log_handlers = [logging.StreamHandler()]
for handler_config in log_handler_confg: for handler_config in log_handler_confg:
@ -34,6 +31,8 @@ class Main():
)) ))
logging.basicConfig(level=logging.DEBUG, handlers=log_handlers) logging.basicConfig(level=logging.DEBUG, handlers=log_handlers)
logging.info("logging init finish") logging.info("logging init finish")
except KeyError:
return
def __init__(self) -> None: def __init__(self) -> None:
self.init_log_handlers() self.init_log_handlers()