4

I've enabled the Devel query log, and it's logging most queries as expected. However, I've got this module which connects to another database and executes a few queries against that one. All queries goes through db_select(), db_query(), db_insert(), db_delete() or db_update().

However, queries executed against the other database (connection is configured on the fly, and not through the settings.php file) never appears in the query log.

Any way I can make it work, so that ALL queries appear in query log at the bottom of the page?

Note: Caching does not seem to have anything to do with it. I've cleared all caches, returned to the page, and still no queries appear in the query log.

  • Interesting question. Just to rule it out, have you checked if caching has anything to do with this? – Citricguy Aug 28 '12 at 10:24
  • Caching does not seem to have anything to do with it. I've cleared all caches, returned to the page, and still no queries appear in the query log. – sbrattla Aug 28 '12 at 10:41
3

It's because Devel uses the Database::getLog() static method to get a list of the queries that have run for the page.

That method can only be run for a single connection at a time, and Devel specifically requests logs for the 'default' database connection (see devel_shutdown_real()):

$queries = (devel_query_enabled() ? Database::getLog('devel', 'default') : NULL);

In short you've got 2 options that I can think of:

  1. Edit the devel module file directly, forcing it to loop through all available connections and combine the query logs (obviously hacking contrib modules is not recommended though)
  2. Implement your own logic in a custom module and have a second set of query logs appear at the bottom of your page. The devel_shutdown() function and devel_shutdown_real() should give you all the code you need to get started if you go down this route.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.