summaryrefslogtreecommitdiffstats
path: root/lib/toaster/toastermain/settings.py
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-11-05 13:30:31 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-11-12 17:04:15 +0000
commit54fd0a76fa3154adfab5688ecc96963f42cded11 (patch)
treeff32b56e94d799974c37919c2b3c6e3d371ddf0c /lib/toaster/toastermain/settings.py
parentd42784432f927f58730caf80546c66772e0fec89 (diff)
downloadbitbake-contrib-54fd0a76fa3154adfab5688ecc96963f42cded11.tar.gz
toaster: SQL query logging
We add a logger, enabled through the settings.py, that logs all SQL queries, with timestamp and duration, to console. This is helpful in profiling the SQL queries. The facility is disabled by default. Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Diffstat (limited to 'lib/toaster/toastermain/settings.py')
-rw-r--r--lib/toaster/toastermain/settings.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/toaster/toastermain/settings.py b/lib/toaster/toastermain/settings.py
index 42581f2df..8de3b52f3 100644
--- a/lib/toaster/toastermain/settings.py
+++ b/lib/toaster/toastermain/settings.py
@@ -24,6 +24,10 @@
DEBUG = True
TEMPLATE_DEBUG = DEBUG
+# Set to True to see the SQL queries in console
+SQL_DEBUG = False
+
+
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
@@ -276,11 +280,21 @@ LOGGING = {
'()': 'django.utils.log.RequireDebugFalse'
}
},
+ 'formatters': {
+ 'datetime': {
+ 'format': 'DB %(asctime)s %(message)s'
+ }
+ },
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
+ },
+ 'console': {
+ 'level': 'DEBUG',
+ 'class': 'logging.StreamHandler',
+ 'formatter': 'datetime',
}
},
'loggers': {
@@ -292,6 +306,13 @@ LOGGING = {
}
}
+if DEBUG and SQL_DEBUG:
+ LOGGING['loggers']['django.db.backends'] = {
+ 'level': 'DEBUG',
+ 'handlers': ['console'],
+ }
+
+
# If we're using sqlite, we need to tweak the performance a bit
from django.db.backends.signals import connection_created
def activate_synchronous_off(sender, connection, **kwargs):