This commit is contained in:
0Xiao0
2025-02-06 09:53:47 +08:00
parent d6d968a4a0
commit d2ac2e716d

10
main.py
View File

@ -11,10 +11,13 @@ import yaml
@singleton @singleton
class Main(): class Main():
def __init__(self) -> None: 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:
return
if config["log"]["handlers"] is None:
return
log_handler_confg = config["log"]["handlers"] log_handler_confg = config["log"]["handlers"]
log_handlers = [] log_handlers = []
for handler_config in log_handler_confg: for handler_config in log_handler_confg:
@ -31,6 +34,9 @@ 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")
def __init__(self) -> None:
self.init_log_handlers()
def run(self): def run(self):
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)