import uvicorn
import logging
from injector import Injector,inject
from src.log.handler import LogHandler
from src.configuration import EnvConf, LogConf, singleton

@singleton
class Main():

    @inject
    def __init__(self, logConf: LogConf) -> None:
        logging.basicConfig(level=logConf.level,filename=logConf.filename,format="%(asctime)s %(levelname)s %(message)s")

    def run(self):
        logger = logging.getLogger(__name__)
        logger.info("jarvis-models start", extra={"version": "0.0.1"})
        uvicorn.run("server:app", host="0.0.0.0", port=8000, log_level="info")

if __name__ == "__main__":
    injector = Injector()
    main = injector.get(Main)
    main.run()