feat: log

This commit is contained in:
superobk
2024-04-30 17:59:37 +08:00
parent 884a835cae
commit 54ddb8ee4a
9 changed files with 81 additions and 31 deletions

13
src/log/handler.py Normal file
View File

@ -0,0 +1,13 @@
import logging
class LogHandler(logging.Handler):
def __init__(self)-> None:
logging.Handler.__init__(self=self)
def emit(self, record) -> None:
print("emit", record)
def handle(self, record) -> None:
print("@ handle",record)

View File

@ -1,15 +0,0 @@
import logging
from injector import singleton, inject
from ..configuration import LogConf
@singleton
class Logger(logging.Logger):
@inject
def __init__(self, config: LogConf) -> None:
super().__init__(__name__)
self.setLevel(config.level)
self.addHandler(logging.StreamHandler())
self.addHandler(logging.FileHandler('log.log'))