From d086fa3aed34a05d52e73c255ca22379149a64a1 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Mon, 20 Jan 2014 09:39:34 +0000 Subject: bitbake: toasterui: add extra debug and development infos We update and add logs throughout the code in order to help with development. The extra logging is turned off by default, but it can be enabled by using environment variables. All logging happens through the Python logging facilities. The toaster UI will save a log of all incoming events if the TOASTER_EVENTLOG variable is set. If TOASTER_SQLDEBUG is set all DB queries will be logged. If TOASTER_DEVEL is set and the django-fresh module is available, the module is enabled to allow auto-reload of pages when the source is changed. (Bitbake rev: 10c27450601b4d24bbb273bd0e053498807d1060) Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastermain/settings.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'bitbake/lib/toaster/toastermain/settings.py') diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py index 0974b90525..acc20cc11d 100644 --- a/bitbake/lib/toaster/toastermain/settings.py +++ b/bitbake/lib/toaster/toastermain/settings.py @@ -21,11 +21,15 @@ # Django settings for Toaster project. +import os, re + DEBUG = True TEMPLATE_DEBUG = DEBUG # Set to True to see the SQL queries in console SQL_DEBUG = False +if os.environ.get("TOASTER_SQLDEBUG", None) is not None: + SQL_DEBUG = True ADMINS = ( @@ -46,7 +50,6 @@ DATABASES = { } # Reinterpret database settings if we have DATABASE_URL environment variable defined -import os, re if 'DATABASE_URL' in os.environ: dburl = os.environ['DATABASE_URL'] @@ -212,6 +215,9 @@ MIDDLEWARE_CLASSES = ( # 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) +from os.path import dirname as DN +SITE_ROOT=DN(DN(os.path.abspath(__file__))) + ROOT_URLCONF = 'toastermain.urls' # Python dotted path to the WSGI application used by Django's runserver. @@ -245,6 +251,19 @@ INSTALLED_APPS = ( 'south', ) + +# Load django-fresh is TOASTER_DEVEL is set, and the module is available +FRESH_ENABLED = False +if os.environ.get('TOASTER_DEVEL', None) is not None: + try: + import fresh + MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + ("fresh.middleware.FreshMiddleware",) + INSTALLED_APPS = INSTALLED_APPS + ('fresh',) + FRESH_ENABLED = True + except: + pass + + SOUTH_TESTS_MIGRATE = False # if we run in managed mode, we need user support @@ -286,7 +305,7 @@ LOGGING = { }, 'formatters': { 'datetime': { - 'format': 'DB %(asctime)s %(message)s' + 'format': '%(levelname)s %(asctime)s %(message)s' } }, 'handlers': { @@ -302,6 +321,10 @@ LOGGING = { } }, 'loggers': { + 'toaster' : { + 'handlers': ['console'], + 'level': 'DEBUG', + }, 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', -- cgit v1.2.3-54-g00ecf