log_level setting
This commit is contained in:
parent
ea85164063
commit
9349f5b756
2 changed files with 8 additions and 5 deletions
|
@ -9,6 +9,8 @@ import logging.config
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from .settings import SETTINGS
|
||||||
|
|
||||||
|
|
||||||
class LogConfig(BaseModel):
|
class LogConfig(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
@ -16,16 +18,13 @@ class LogConfig(BaseModel):
|
||||||
https://stackoverflow.com/a/67937084
|
https://stackoverflow.com/a/67937084
|
||||||
"""
|
"""
|
||||||
|
|
||||||
LOG_FORMAT: str = "%(levelprefix)s [%(asctime)s] %(name)s: %(message)s"
|
|
||||||
LOG_LEVEL: str = "DEBUG"
|
|
||||||
|
|
||||||
# Logging config
|
# Logging config
|
||||||
version = 1
|
version = 1
|
||||||
disable_existing_loggers = False
|
disable_existing_loggers = False
|
||||||
formatters = {
|
formatters = {
|
||||||
"default": {
|
"default": {
|
||||||
"()": "uvicorn.logging.DefaultFormatter",
|
"()": "uvicorn.logging.DefaultFormatter",
|
||||||
"fmt": LOG_FORMAT,
|
"fmt": "%(levelprefix)s [%(asctime)s] %(name)s: %(message)s",
|
||||||
"datefmt": "%Y-%m-%d %H:%M:%S",
|
"datefmt": "%Y-%m-%d %H:%M:%S",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -37,7 +36,10 @@ class LogConfig(BaseModel):
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
loggers = {
|
loggers = {
|
||||||
"ovdashboard_api": {"handlers": ["default"], "level": LOG_LEVEL},
|
"ovdashboard_api": {
|
||||||
|
"handlers": ["default"],
|
||||||
|
"level": SETTINGS.log_level,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ class Settings(BaseSettings):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
production_mode: bool = False
|
production_mode: bool = False
|
||||||
|
log_level: str = "DEBUG"
|
||||||
api_v1_prefix: str = "api/v1"
|
api_v1_prefix: str = "api/v1"
|
||||||
openapi_url: str = "/openapi.json"
|
openapi_url: str = "/openapi.json"
|
||||||
docs_url: Optional[str] = "/docs"
|
docs_url: Optional[str] = "/docs"
|
||||||
|
|
Loading…
Reference in a new issue