diff --git a/.gitignore b/.gitignore index e4c3af3..999156e 100644 --- a/.gitignore +++ b/.gitignore @@ -164,4 +164,5 @@ cython_debug/ playground.py .env* models -.idea/ \ No newline at end of file +.idea/ +promtail/ \ No newline at end of file diff --git a/main.py b/main.py index 607ceb4..4cafad9 100644 --- a/main.py +++ b/main.py @@ -6,10 +6,10 @@ from src.configuration import EnvConf, LogConf, singleton @singleton class Main(): - env_conf: EnvConf + @inject - def __init__(self, log_config: LogConf, env_conf: EnvConf) -> None: - self.env_conf=env_conf + 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__) diff --git a/src/configuration.py b/src/configuration.py index f99ebac..bb4e749 100644 --- a/src/configuration.py +++ b/src/configuration.py @@ -69,7 +69,7 @@ DEFAULT_TIME_FORMAT="%Y-%m-%d %H:%M:%S" class LogConf(): level: int time_format = "%Y-%m-%d %H:%M:%S" - + filename: str | None @inject def __init__(self,config: Configuration) -> None: self.level = config.get("log.level") @@ -79,12 +79,13 @@ class LogConf(): self.level = logging.WARNING else: self.level = level - self.time_format=config.get("log.time_format", default=DEFAULT_TIME_FORMAT) + self.filename = config.get("log.filename") + self.time_format = config.get("log.time_format", default=DEFAULT_TIME_FORMAT) @singleton class EnvConf(): version: str @inject - def __init__(self, config: Configuration) -> None: - self.version = config.get("env.version") + def __init__(self) -> None: + self.version = "0.0.1"