mirror of
https://git.yoctoproject.org/poky
synced 2026-05-02 18:32:15 +02:00
bitbake: 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. (Bitbake rev: 54fd0a76fa3154adfab5688ecc96963f42cded11) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
3e9fc8d091
commit
990fb9ed6c
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user