Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions dakara_server/dakara_server/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@

TIME_ZONE = config("TIME_ZONE", default="UTC")

logfile_handler = {}
handlers = ["console_playlist"]
if config("LOG_FILE_PATH", default=""):
logfile_handler = {
"logfile": {
"level": "DEBUG",
"class": "logging.handlers.RotatingFileHandler",
"filename": config("LOG_FILE_PATH"),
"maxBytes": config("LOG_FILE_MAX_SIZE", cast=int),
"backupCount": config("LOG_FILE_BACKUP_COUNT", cast=int),
"formatter": "default",
},
}
handlers = ["logfile"]


# Loggin config
LOGGING = {
"version": 1,
Expand All @@ -69,19 +85,12 @@
"class": "logging.StreamHandler",
"formatter": "no_time",
},
"logfile": {
"level": "DEBUG",
"class": "logging.handlers.RotatingFileHandler",
"filename": config("LOG_FILE_PATH"),
"maxBytes": config("LOG_FILE_MAX_SIZE", cast=int),
"backupCount": config("LOG_FILE_BACKUP_COUNT", cast=int),
"formatter": "default",
},
**logfile_handler,
},
"loggers": {
"playlist.views": {"handlers": ["logfile"], "level": "INFO"},
"playlist.date_stop": {"handlers": ["logfile"], "level": "INFO"},
"playlist.consumers": {"handlers": ["logfile"], "level": "INFO"},
"playlist.views": {"handlers": handlers, "level": "INFO"},
"playlist.date_stop": {"handlers": handlers, "level": "INFO"},
"playlist.consumers": {"handlers": handlers, "level": "INFO"},
"library.management.commands.feed": {
"handlers": ["console_interactive"],
"level": "INFO",
Expand All @@ -91,7 +100,7 @@
"level": "INFO",
},
"django": {
"handlers": ["logfile"],
"handlers": handlers,
"level": config("DJANGO_LOG_LEVEL", default="INFO"),
},
},
Expand Down