mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
feat: logging init
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -165,3 +165,4 @@ playground.py
|
|||||||
.env*
|
.env*
|
||||||
models
|
models
|
||||||
.idea/
|
.idea/
|
||||||
|
promtail/
|
||||||
6
main.py
6
main.py
@ -6,10 +6,10 @@ from src.configuration import EnvConf, LogConf, singleton
|
|||||||
|
|
||||||
@singleton
|
@singleton
|
||||||
class Main():
|
class Main():
|
||||||
env_conf: EnvConf
|
|
||||||
@inject
|
@inject
|
||||||
def __init__(self, log_config: LogConf, env_conf: EnvConf) -> None:
|
def __init__(self, logConf: LogConf) -> None:
|
||||||
self.env_conf=env_conf
|
logging.basicConfig(level=logConf.level,filename=logConf.filename,format="%(asctime)s %(levelname)s %(message)s")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@ -69,7 +69,7 @@ DEFAULT_TIME_FORMAT="%Y-%m-%d %H:%M:%S"
|
|||||||
class LogConf():
|
class LogConf():
|
||||||
level: int
|
level: int
|
||||||
time_format = "%Y-%m-%d %H:%M:%S"
|
time_format = "%Y-%m-%d %H:%M:%S"
|
||||||
|
filename: str | None
|
||||||
@inject
|
@inject
|
||||||
def __init__(self,config: Configuration) -> None:
|
def __init__(self,config: Configuration) -> None:
|
||||||
self.level = config.get("log.level")
|
self.level = config.get("log.level")
|
||||||
@ -79,6 +79,7 @@ class LogConf():
|
|||||||
self.level = logging.WARNING
|
self.level = logging.WARNING
|
||||||
else:
|
else:
|
||||||
self.level = level
|
self.level = level
|
||||||
|
self.filename = config.get("log.filename")
|
||||||
self.time_format = config.get("log.time_format", default=DEFAULT_TIME_FORMAT)
|
self.time_format = config.get("log.time_format", default=DEFAULT_TIME_FORMAT)
|
||||||
|
|
||||||
@singleton
|
@singleton
|
||||||
@ -86,5 +87,5 @@ class EnvConf():
|
|||||||
version: str
|
version: str
|
||||||
|
|
||||||
@inject
|
@inject
|
||||||
def __init__(self, config: Configuration) -> None:
|
def __init__(self) -> None:
|
||||||
self.version = config.get("env.version")
|
self.version = "0.0.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user