mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
feat: log
This commit is contained in:
3
main.py
3
main.py
@ -7,12 +7,11 @@ from src.configuration import EnvConf, LogConf, singleton
|
||||
@singleton
|
||||
class Main():
|
||||
env_conf: EnvConf
|
||||
|
||||
@inject
|
||||
def __init__(self, log_config: LogConf, env_conf: EnvConf, log_handler: LogHandler) -> None:
|
||||
self.env_conf=env_conf
|
||||
logging.basicConfig(
|
||||
handlers=[logging.StreamHandler()],
|
||||
handlers=[log_handler],
|
||||
level=log_config.level,
|
||||
datefmt=log_config.time_format,
|
||||
format='%(asctime)s %(message)s')
|
||||
|
||||
@ -4,8 +4,6 @@ from typing import Any, Coroutine
|
||||
from fastapi import Request, Response, status
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from ..log.log import Logger
|
||||
|
||||
from ..asr.rapid_paraformer.utils import read_yaml
|
||||
from ..asr.rapid_paraformer import RapidParaformer
|
||||
from .blackbox import Blackbox
|
||||
@ -15,8 +13,7 @@ from injector import singleton, inject
|
||||
class ASR(Blackbox):
|
||||
|
||||
@inject
|
||||
def __init__(self,logger: Logger,path = ".env.yaml") -> None:
|
||||
logger.info("ASR init")
|
||||
def __init__(self,path = ".env.yaml") -> None:
|
||||
config = read_yaml(path)
|
||||
self.paraformer = RapidParaformer(config)
|
||||
|
||||
|
||||
@ -8,6 +8,3 @@ class LogHandler(logging.StreamHandler):
|
||||
def emit(self, record) -> None:
|
||||
print("emit", record)
|
||||
|
||||
def handle(self, record) -> None:
|
||||
print("@ handle",record)
|
||||
|
||||
@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user