diff --git a/api/ovdashboard_api/__init__.py b/api/ovdashboard_api/__init__.py index aee62c4..ae8c6e6 100644 --- a/api/ovdashboard_api/__init__.py +++ b/api/ovdashboard_api/__init__.py @@ -9,6 +9,8 @@ import logging.config from pydantic import BaseModel +from .settings import SETTINGS + class LogConfig(BaseModel): """ @@ -16,16 +18,13 @@ class LogConfig(BaseModel): https://stackoverflow.com/a/67937084 """ - LOG_FORMAT: str = "%(levelprefix)s [%(asctime)s] %(name)s: %(message)s" - LOG_LEVEL: str = "DEBUG" - # Logging config version = 1 disable_existing_loggers = False formatters = { "default": { "()": "uvicorn.logging.DefaultFormatter", - "fmt": LOG_FORMAT, + "fmt": "%(levelprefix)s [%(asctime)s] %(name)s: %(message)s", "datefmt": "%Y-%m-%d %H:%M:%S", }, } @@ -37,7 +36,10 @@ class LogConfig(BaseModel): }, } loggers = { - "ovdashboard_api": {"handlers": ["default"], "level": LOG_LEVEL}, + "ovdashboard_api": { + "handlers": ["default"], + "level": SETTINGS.log_level, + }, } diff --git a/api/ovdashboard_api/settings.py b/api/ovdashboard_api/settings.py index 3dceb79..1877c14 100644 --- a/api/ovdashboard_api/settings.py +++ b/api/ovdashboard_api/settings.py @@ -48,6 +48,7 @@ class Settings(BaseSettings): """ production_mode: bool = False + log_level: str = "DEBUG" api_v1_prefix: str = "api/v1" openapi_url: str = "/openapi.json" docs_url: Optional[str] = "/docs"