ovdashboard/api/ovdashboard_api/__init__.py

45 lines
1,005 B
Python
Raw Normal View History

2022-09-05 12:54:02 +00:00
"""
2022-09-05 12:58:00 +00:00
Package `ovdashboard_api`: Contains the API powering the
2022-09-05 12:54:02 +00:00
"OVDashboard" application.
This file: Sets up logging.
"""
2022-09-04 23:25:40 +00:00
import logging.config
from pydantic import BaseModel
class LogConfig(BaseModel):
"""
Logging configuration to be set for the server.
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,
"datefmt": "%Y-%m-%d %H:%M:%S",
},
}
handlers = {
"default": {
"formatter": "default",
"class": "logging.StreamHandler",
"stream": "ext://sys.stderr",
},
}
loggers = {
"ovdashboard_api": {"handlers": ["default"], "level": LOG_LEVEL},
}
2022-09-04 23:25:40 +00:00
logging.config.dictConfig(LogConfig().dict())