Files
digest_app/module_project/settings/production.py
2024-05-21 19:40:57 +05:30

86 lines
2.3 KiB
Python

from .base import * # noqa
from .base import env, BASE_DIR
import os
import colorlog
from logging.handlers import TimedRotatingFileHandler
DEBUG = False
ALLOWED_HOSTS = ["admin.eatwithdigest.com"]
# CORS_ALLOWED_ORIGINS = [
# "http://127.0.0.1:3000",
# ]
CORS_ORIGIN_ALLOW_ALL = True
# CORS_ORIGIN_WHITELIST = ("http://localhost:3000",)
LOGGING_DIR = os.path.join(
BASE_DIR, "logs"
) # Define the directory where log files will be stored
# Ensure the directory exists; create it if it doesn't
if not os.path.exists(LOGGING_DIR):
os.makedirs(LOGGING_DIR)
LOGGING_LEVEL = env.str(
"LOG_LEVEL", "INFO"
) # Set your desired log level (e.g., DEBUG, INFO, WARNING, ERROR) in the env file
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"verbose": {
"()": colorlog.ColoredFormatter,
"format": "%(cyan)s%(asctime)s%(reset)s | %(red)s[%(levelname)8s]%(reset)s | [ %(yellow)s%(name)s.%(module)s:%(white)s%(lineno)d%(reset)s - %(green)s%(funcName)10s()%(reset)s ] --> %(message)s",
"datefmt": "%Y-%m-%d %H:%M:%S",
"log_colors": {
"DEBUG": "white",
"INFO": "green",
"WARNING": "yellow",
"ERROR": "red",
"CRITICAL": "bold_red",
},
"secondary_log_colors": {},
"style": "%",
}
},
"handlers": {
"logfile": {
"level": LOGGING_LEVEL,
"class": "logging.handlers.RotatingFileHandler",
"filename": os.path.join(LOGGING_DIR, "errors.log"),
'maxBytes': 5242880, # 5*1024*1024 bytes (5MB)
"backupCount": 10, # Number of log files to keep (15 days' worth of logs)
"formatter": "verbose",
},
},
"loggers": {
"django": {
"handlers": ["logfile"],
"level": LOGGING_LEVEL,
"propagate": False,
},
},
}
BASE_DOMAIN = "https://admin.eatwithdigest.com"
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = "/static/"
# STATICFILES_DIRS = [BASE_DIR.joinpath("static")]