feat(api): allow to run without log file for dev

BREAKING CHANGE: moved production api log file
from '/var/log/airtime/api.log' to '/var/log/libretime/api.log'
This commit is contained in:
jo 2022-01-15 18:22:24 +01:00 committed by Kyle Robbertze
parent 401808d7d1
commit bf59f20ffd
2 changed files with 22 additions and 18 deletions

View File

@ -2,6 +2,8 @@
Description=LibreTime API Service
[Service]
Environment=LIBRETIME_LOG_FILEPATH=/var/log/libretime/api.log
ExecStart=/usr/bin/uwsgi /etc/airtime/libretime-api.ini
User=libretime-api
Group=libretime-api

View File

@ -148,6 +148,23 @@ AUTH_USER_MODEL = "libretime_api.User"
TEST_RUNNER = "libretime_api.tests.runners.ManagedModelTestRunner"
LOGGING_HANDLERS = {
"console": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "simple",
},
}
if LIBRETIME_LOG_FILEPATH is not None:
LOGGING_HANDLERS["file"] = {
"level": "DEBUG",
"class": "logging.FileHandler",
"filename": LIBRETIME_LOG_FILEPATH,
"formatter": "verbose",
}
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
@ -161,30 +178,15 @@ LOGGING = {
"style": "{",
},
},
"handlers": {
"file": {
"level": "DEBUG",
"class": "logging.FileHandler",
"filename": os.path.join(
CONFIG.get("pypo", "log_base_dir", fallback=".").replace("'", ""),
"api.log",
),
"formatter": "verbose",
},
"console": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "simple",
},
},
"handlers": LOGGING_HANDLERS,
"loggers": {
"django": {
"handlers": ["file", "console"],
"handlers": LOGGING_HANDLERS.keys(),
"level": "INFO",
"propagate": True,
},
"libretime_api": {
"handlers": ["file", "console"],
"handlers": LOGGING_HANDLERS.keys(),
"level": "INFO",
"propagate": True,
},