46 lines
1,018 B
Python
46 lines
1,018 B
Python
"""
|
|
Package `ovdashboard_api`: Contains the API powering the
|
|
"OVDashboard" application.
|
|
|
|
This file: Sets up logging.
|
|
"""
|
|
|
|
import logging.config
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from .settings import SETTINGS
|
|
|
|
|
|
class LogConfig(BaseModel):
|
|
"""
|
|
Logging configuration to be set for the server.
|
|
https://stackoverflow.com/a/67937084
|
|
"""
|
|
|
|
# Logging config
|
|
version = 1
|
|
disable_existing_loggers = False
|
|
formatters = {
|
|
"default": {
|
|
"()": "uvicorn.logging.DefaultFormatter",
|
|
"fmt": "%(levelprefix)s [%(asctime)s] %(name)s: %(message)s",
|
|
"datefmt": "%Y-%m-%d %H:%M:%S",
|
|
},
|
|
}
|
|
handlers = {
|
|
"default": {
|
|
"formatter": "default",
|
|
"class": "logging.StreamHandler",
|
|
"stream": "ext://sys.stderr",
|
|
},
|
|
}
|
|
loggers = {
|
|
"ovdashboard_api": {
|
|
"handlers": ["default"],
|
|
"level": SETTINGS.log_level,
|
|
},
|
|
}
|
|
|
|
|
|
logging.config.dictConfig(LogConfig().dict())
|