Files
digest_app/module_project/settings/production.py
2024-02-26 13:28:32 +05:30

88 lines
2.2 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 = []
# CORS_ALLOWED_ORIGINS = [
# # "http://127.0.0.1:3000",
# ]
# CORS_ORIGIN_ALLOW_ALL = True
# CORS_ORIGIN_WHITELIST = ("",)
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)
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 = ""
# 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")]