diff options
Diffstat (limited to 'bitbake/lib/toaster/toastermain/settings.py')
-rw-r--r-- | bitbake/lib/toaster/toastermain/settings.py | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py index 609c85d9d8..b083cf5885 100644 --- a/bitbake/lib/toaster/toastermain/settings.py +++ b/bitbake/lib/toaster/toastermain/settings.py | |||
@@ -9,6 +9,8 @@ | |||
9 | # Django settings for Toaster project. | 9 | # Django settings for Toaster project. |
10 | 10 | ||
11 | import os | 11 | import os |
12 | from pathlib import Path | ||
13 | from toastermain.logs import LOGGING_SETTINGS | ||
12 | 14 | ||
13 | DEBUG = True | 15 | DEBUG = True |
14 | 16 | ||
@@ -186,7 +188,13 @@ TEMPLATES = [ | |||
186 | 'django.template.loaders.app_directories.Loader', | 188 | 'django.template.loaders.app_directories.Loader', |
187 | #'django.template.loaders.eggs.Loader', | 189 | #'django.template.loaders.eggs.Loader', |
188 | ], | 190 | ], |
189 | 'string_if_invalid': InvalidString("%s"), | 191 | # https://docs.djangoproject.com/en/4.2/ref/templates/api/#how-invalid-variables-are-handled |
192 | # Generally, string_if_invalid should only be enabled in order to debug | ||
193 | # a specific template problem, then cleared once debugging is complete. | ||
194 | # If you assign a value other than '' to string_if_invalid, | ||
195 | # you will experience rendering problems with these templates and sites. | ||
196 | # 'string_if_invalid': InvalidString("%s"), | ||
197 | 'string_if_invalid': "", | ||
190 | 'debug': DEBUG, | 198 | 'debug': DEBUG, |
191 | }, | 199 | }, |
192 | }, | 200 | }, |
@@ -242,6 +250,9 @@ INSTALLED_APPS = ( | |||
242 | 'django.contrib.humanize', | 250 | 'django.contrib.humanize', |
243 | 'bldcollector', | 251 | 'bldcollector', |
244 | 'toastermain', | 252 | 'toastermain', |
253 | |||
254 | # 3rd-lib | ||
255 | "log_viewer", | ||
245 | ) | 256 | ) |
246 | 257 | ||
247 | 258 | ||
@@ -302,43 +313,22 @@ for t in os.walk(os.path.dirname(currentdir)): | |||
302 | # the site admins on every HTTP 500 error when DEBUG=False. | 313 | # the site admins on every HTTP 500 error when DEBUG=False. |
303 | # See http://docs.djangoproject.com/en/dev/topics/logging for | 314 | # See http://docs.djangoproject.com/en/dev/topics/logging for |
304 | # more details on how to customize your logging configuration. | 315 | # more details on how to customize your logging configuration. |
305 | LOGGING = { | 316 | LOGGING = LOGGING_SETTINGS |
306 | 'version': 1, | 317 | |
307 | 'disable_existing_loggers': False, | 318 | # Build paths inside the project like this: BASE_DIR / 'subdir'. |
308 | 'filters': { | 319 | BASE_DIR = Path(__file__).resolve(strict=True).parent.parent |
309 | 'require_debug_false': { | 320 | |
310 | '()': 'django.utils.log.RequireDebugFalse' | 321 | # LOG VIEWER |
311 | } | 322 | # https://pypi.org/project/django-log-viewer/ |
312 | }, | 323 | LOG_VIEWER_FILES_PATTERN = '*.log*' |
313 | 'formatters': { | 324 | LOG_VIEWER_FILES_DIR = os.path.join(BASE_DIR, 'logs') |
314 | 'datetime': { | 325 | LOG_VIEWER_PAGE_LENGTH = 25 # total log lines per-page |
315 | 'format': '%(asctime)s %(levelname)s %(message)s' | 326 | LOG_VIEWER_MAX_READ_LINES = 100000 # total log lines will be read |
316 | } | 327 | LOG_VIEWER_PATTERNS = ['INFO', 'DEBUG', 'WARNING', 'ERROR', 'CRITICAL'] |
317 | }, | 328 | |
318 | 'handlers': { | 329 | # Optionally you can set the next variables in order to customize the admin: |
319 | 'mail_admins': { | 330 | LOG_VIEWER_FILE_LIST_TITLE = "Logs list" |
320 | 'level': 'ERROR', | 331 | |
321 | 'filters': ['require_debug_false'], | ||
322 | 'class': 'django.utils.log.AdminEmailHandler' | ||
323 | }, | ||
324 | 'console': { | ||
325 | 'level': 'DEBUG', | ||
326 | 'class': 'logging.StreamHandler', | ||
327 | 'formatter': 'datetime', | ||
328 | } | ||
329 | }, | ||
330 | 'loggers': { | ||
331 | 'toaster' : { | ||
332 | 'handlers': ['console'], | ||
333 | 'level': 'DEBUG', | ||
334 | }, | ||
335 | 'django.request': { | ||
336 | 'handlers': ['console'], | ||
337 | 'level': 'WARN', | ||
338 | 'propagate': True, | ||
339 | }, | ||
340 | } | ||
341 | } | ||
342 | 332 | ||
343 | if DEBUG and SQL_DEBUG: | 333 | if DEBUG and SQL_DEBUG: |
344 | LOGGING['loggers']['django.db.backends'] = { | 334 | LOGGING['loggers']['django.db.backends'] = { |