40 lines
929 B
Python
40 lines
929 B
Python
"""
|
|
Package `ovdashboard_api`: Contains the API powering the
|
|
"OVDashboard" application.
|
|
|
|
This file: Sets up logging.
|
|
"""
|
|
|
|
from logging.config import dictConfig
|
|
|
|
from .core.settings import SETTINGS
|
|
|
|
# Logging configuration to be set for the server.
|
|
# https://stackoverflow.com/a/67937084
|
|
|
|
LOG_CONFIG = dict(
|
|
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,
|
|
},
|
|
},
|
|
)
|
|
|
|
dictConfig(LOG_CONFIG)
|