feat: add configurable log level
All checks were successful
Build and Push Docker Image / build (push) Successful in 24s
All checks were successful
Build and Push Docker Image / build (push) Successful in 24s
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
SECRET_KEY=replace-me
|
SECRET_KEY=replace-me
|
||||||
DEBUG=false
|
DEBUG=false
|
||||||
|
LOG_LEVEL=INFO
|
||||||
ALLOWED_HOSTS=example.com,www.example.com
|
ALLOWED_HOSTS=example.com,www.example.com
|
||||||
CSRF_TRUSTED_ORIGINS=https://example.com,https://www.example.com
|
CSRF_TRUSTED_ORIGINS=https://example.com,https://www.example.com
|
||||||
USE_X_FORWARDED_HOST=true
|
USE_X_FORWARDED_HOST=true
|
||||||
|
|||||||
@@ -57,6 +57,17 @@ def env_pair(name: str, default: tuple[str, str]) -> tuple[str, str]:
|
|||||||
return parts[0], parts[1]
|
return parts[0], parts[1]
|
||||||
|
|
||||||
|
|
||||||
|
def env_log_level(name: str, default: str = "INFO") -> str:
|
||||||
|
value = os.getenv(name, default)
|
||||||
|
if not value:
|
||||||
|
return default
|
||||||
|
|
||||||
|
normalized = value.strip().upper()
|
||||||
|
if normalized not in {"CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"}:
|
||||||
|
return default
|
||||||
|
return normalized
|
||||||
|
|
||||||
|
|
||||||
def merge_unique(*value_lists: list[str]) -> list[str]:
|
def merge_unique(*value_lists: list[str]) -> list[str]:
|
||||||
merged: list[str] = []
|
merged: list[str] = []
|
||||||
seen: set[str] = set()
|
seen: set[str] = set()
|
||||||
@@ -298,3 +309,57 @@ EMAIL_USE_TLS = env_bool('EMAIL_USE_TLS', False)
|
|||||||
EMAIL_USE_SSL = env_bool('EMAIL_USE_SSL', False)
|
EMAIL_USE_SSL = env_bool('EMAIL_USE_SSL', False)
|
||||||
DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'no-reply@santehray.local')
|
DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'no-reply@santehray.local')
|
||||||
ADMINISTRATOR_EMAIL = os.getenv('ADMINISTRATOR_EMAIL', 'info@santehray.by')
|
ADMINISTRATOR_EMAIL = os.getenv('ADMINISTRATOR_EMAIL', 'info@santehray.by')
|
||||||
|
|
||||||
|
LOG_LEVEL = env_log_level("LOG_LEVEL", "INFO")
|
||||||
|
|
||||||
|
LOGGING = {
|
||||||
|
"version": 1,
|
||||||
|
"disable_existing_loggers": False,
|
||||||
|
"formatters": {
|
||||||
|
"verbose": {
|
||||||
|
"format": "%(levelname)s %(asctime)s %(name)s %(message)s",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"handlers": {
|
||||||
|
"console": {
|
||||||
|
"class": "logging.StreamHandler",
|
||||||
|
"formatter": "verbose",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"handlers": ["console"],
|
||||||
|
"level": LOG_LEVEL,
|
||||||
|
},
|
||||||
|
"loggers": {
|
||||||
|
"django": {
|
||||||
|
"handlers": ["console"],
|
||||||
|
"level": LOG_LEVEL,
|
||||||
|
"propagate": False,
|
||||||
|
},
|
||||||
|
"django.request": {
|
||||||
|
"handlers": ["console"],
|
||||||
|
"level": LOG_LEVEL,
|
||||||
|
"propagate": False,
|
||||||
|
},
|
||||||
|
"home": {
|
||||||
|
"handlers": ["console"],
|
||||||
|
"level": LOG_LEVEL,
|
||||||
|
"propagate": False,
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
"handlers": ["console"],
|
||||||
|
"level": LOG_LEVEL,
|
||||||
|
"propagate": False,
|
||||||
|
},
|
||||||
|
"orders": {
|
||||||
|
"handlers": ["console"],
|
||||||
|
"level": LOG_LEVEL,
|
||||||
|
"propagate": False,
|
||||||
|
},
|
||||||
|
"users": {
|
||||||
|
"handlers": ["console"],
|
||||||
|
"level": LOG_LEVEL,
|
||||||
|
"propagate": False,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user