Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be convenient to have a way to log queries passed to MongoDB during a page cycle, much like the query trace offered by Devel module on \Database
.
Boris (drush core-cli) shows query cursors quite nicely, like this:
$q = $c->find(['pid' => ['$gt' => 5]], [_id => 0, started_iterating => 0, dead => 0])
->sort(['pid' => -1])
->skip(5)
->limit(10);
MongoCursor {#294 ns: "ninja.url_alias" limit: 10 batchSize: 0 skip: 5 flags: 0 query: array:2 [ "$query" => array:1 [ "pid" => array:1 [ "$gt" => 5 ] ] "$orderby" => array:1 [ "pid" => -1 ] ] fields: array:3 [ "_id" => 0 "started_iterating" => 0 "dead" => 0 ] started_iterating: false dead: false }
Comments
Comment #2
fgmNote: logging support exists in http://be2.php.net/manual/en/context.mongodb.php by passing up to 7 logging callbacks, for various server responses. None (apparently) for the queries themselves.
Comment #3
fgmBasic implementation could be like this package http://github.com/FGM/mongodb_logger/
Comment #4
mikeytown2 CreditAttribution: mikeytown2 commentedyou can reuse the devel query logger to log just about anything. I do this in apdqc to log non DBTNG queries. http://cgit.drupalcode.org/apdqc/tree/apdqc.log.inc
Comment #5
fgm@mikeytown2 : thanks for the pointer. Interesting project, BTW.
Comment #6
fgmWon't happen in 7.x, bumping to current dev. Even though...
Comment #7
fgmMore info on where this is going at MongoDB Inc.
Given this info, postponing on release 1.4 due for late this summer.