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
|
@singleton
|
||||||
class Main():
|
class Main():
|
||||||
env_conf: EnvConf
|
env_conf: EnvConf
|
||||||
|
|
||||||
@inject
|
@inject
|
||||||
def __init__(self, log_config: LogConf, env_conf: EnvConf, log_handler: LogHandler) -> None:
|
def __init__(self, log_config: LogConf, env_conf: EnvConf, log_handler: LogHandler) -> None:
|
||||||
self.env_conf=env_conf
|
self.env_conf=env_conf
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
handlers=[logging.StreamHandler()],
|
handlers=[log_handler],
|
||||||
level=log_config.level,
|
level=log_config.level,
|
||||||
datefmt=log_config.time_format,
|
datefmt=log_config.time_format,
|
||||||
format='%(asctime)s %(message)s')
|
format='%(asctime)s %(message)s')
|
||||||
|
|||||||
@ -4,8 +4,6 @@ from typing import Any, Coroutine
|
|||||||
from fastapi import Request, Response, status
|
from fastapi import Request, Response, status
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
from ..log.log import Logger
|
|
||||||
|
|
||||||
from ..asr.rapid_paraformer.utils import read_yaml
|
from ..asr.rapid_paraformer.utils import read_yaml
|
||||||
from ..asr.rapid_paraformer import RapidParaformer
|
from ..asr.rapid_paraformer import RapidParaformer
|
||||||
from .blackbox import Blackbox
|
from .blackbox import Blackbox
|
||||||
@ -15,8 +13,7 @@ from injector import singleton, inject
|
|||||||
class ASR(Blackbox):
|
class ASR(Blackbox):
|
||||||
|
|
||||||
@inject
|
@inject
|
||||||
def __init__(self,logger: Logger,path = ".env.yaml") -> None:
|
def __init__(self,path = ".env.yaml") -> None:
|
||||||
logger.info("ASR init")
|
|
||||||
config = read_yaml(path)
|
config = read_yaml(path)
|
||||||
self.paraformer = RapidParaformer(config)
|
self.paraformer = RapidParaformer(config)
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,4 @@ class LogHandler(logging.StreamHandler):
|
|||||||
|
|
||||||
def emit(self, record) -> None:
|
def emit(self, record) -> None:
|
||||||
print("emit", record)
|
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