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-07 00:29:32 +00:00
|
|
|
from logging.config import dictConfig
|
2022-09-04 23:25:40 +00:00
|
|
|
|
2023-10-18 16:55:54 +00:00
|
|
|
from .core.settings import SETTINGS
|
2022-09-07 00:17:25 +00:00
|
|
|
|
2023-10-20 08:43:15 +00:00
|
|
|
# Logging configuration to be set for the server.
|
|
|
|
# https://stackoverflow.com/a/67937084
|
2022-09-05 13:11:57 +00:00
|
|
|
|
2023-10-20 08:43:15 +00:00
|
|
|
LOG_CONFIG = dict(
|
|
|
|
version=1,
|
|
|
|
disable_existing_loggers=False,
|
|
|
|
formatters={
|
2022-09-05 13:11:57 +00:00
|
|
|
"default": {
|
|
|
|
"()": "uvicorn.logging.DefaultFormatter",
|
2022-09-07 00:17:25 +00:00
|
|
|
"fmt": "%(levelprefix)s [%(asctime)s] %(name)s: %(message)s",
|
2022-09-05 13:11:57 +00:00
|
|
|
"datefmt": "%Y-%m-%d %H:%M:%S",
|
|
|
|
},
|
2023-10-20 08:43:15 +00:00
|
|
|
},
|
|
|
|
handlers={
|
2022-09-05 13:11:57 +00:00
|
|
|
"default": {
|
|
|
|
"formatter": "default",
|
|
|
|
"class": "logging.StreamHandler",
|
|
|
|
"stream": "ext://sys.stderr",
|
|
|
|
},
|
2023-10-20 08:43:15 +00:00
|
|
|
},
|
|
|
|
loggers={
|
2022-09-07 00:17:25 +00:00
|
|
|
"ovdashboard_api": {
|
|
|
|
"handlers": ["default"],
|
|
|
|
"level": SETTINGS.log_level,
|
|
|
|
},
|
2023-10-20 08:43:15 +00:00
|
|
|
},
|
|
|
|
)
|
2022-09-04 23:25:40 +00:00
|
|
|
|
2023-10-20 08:43:15 +00:00
|
|
|
dictConfig(LOG_CONFIG)
|