|
10 | 10 | https://docs.djangoproject.com/en/4.2/ref/settings/
|
11 | 11 | """
|
12 | 12 | import os
|
| 13 | +from distutils.util import strtobool |
13 | 14 | from pathlib import Path
|
14 | 15 | from typing import Any
|
15 | 16 |
|
|
43 | 44 |
|
44 | 45 |
|
45 | 46 | # SECURITY WARNING: don't run with debug turned on in production!
|
46 |
| -DEBUG: bool = True |
| 47 | +DEBUG = bool(strtobool(os.getenv('DEBUG', 'False'))) |
47 | 48 |
|
48 | 49 |
|
49 | 50 | # SECURITY WARNING: keep the secret key used in production secret!
|
|
158 | 159 | }
|
159 | 160 |
|
160 | 161 |
|
161 |
| -PAGE_SIZE = os.environ.get('PAGE_SIZE', 10) |
| 162 | +PAGE_SIZE: int = int(os.environ.get('PAGE_SIZE', 10)) |
162 | 163 |
|
163 | 164 |
|
164 | 165 | CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
|
|
189 | 190 | ),
|
190 | 191 | }
|
191 | 192 |
|
| 193 | +# Logging |
| 194 | +# https://docs.djangoproject.com/en/4.2/topics/logging/ |
| 195 | + |
| 196 | +LOGGING = { |
| 197 | + 'version': 1, |
| 198 | + 'disable_existing_loggers': False, |
| 199 | + 'formatters': { |
| 200 | + 'simple': { |
| 201 | + 'format': '[%(asctime)s] %(levelname)s | %(name)s | %(message)s', |
| 202 | + 'datefmt': '%Y-%m-%d %H:%M:%S', |
| 203 | + }, |
| 204 | + }, |
| 205 | + 'handlers': { |
| 206 | + 'console': { |
| 207 | + 'class': 'logging.StreamHandler', |
| 208 | + 'formatter': 'simple', |
| 209 | + }, |
| 210 | + 'file': { |
| 211 | + 'class': 'logging.handlers.RotatingFileHandler', |
| 212 | + 'filename': os.path.join(BASE_DIR, 'logs', 'signal_documentation.log'), |
| 213 | + 'formatter': 'simple', |
| 214 | + 'maxBytes': 1024*1024*15, # 15MB |
| 215 | + 'backupCount': 10, |
| 216 | + } |
| 217 | + }, |
| 218 | + 'loggers': { |
| 219 | + 'django': { |
| 220 | + 'handlers': ['file', 'console'], |
| 221 | + 'level': 'INFO', |
| 222 | + }, |
| 223 | + }, |
| 224 | +} |
| 225 | + |
| 226 | +if DEBUG: |
| 227 | + for logger in LOGGING['loggers']: |
| 228 | + LOGGING['loggers'][logger]['handlers'] = ['console'] |
| 229 | + |
192 | 230 |
|
193 | 231 | # DRF Spectacular settings
|
194 | 232 | # https://drf-spectacular.readthedocs.io/en/latest/settings.html
|
|
0 commit comments