|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70326 Incorrect and incomplete list of log callbacks
Submitted: 2015-08-22 14:05 UTC Modified: 2021-08-03 11:41 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: fgm at osinet dot fr Assigned:
Status: Open Package: mongodb (PECL)
PHP Version: 5.6.12 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: fgm at osinet dot fr
New email:
PHP Version: OS:


 [2015-08-22 14:05 UTC] fgm at osinet dot fr
The MongoDB Context Options doc page at omits two such working callbacks:

- log_query, needed to log commands including $query
- log_batchinsert, fto log batch inserts.

And it mentions log_write_batch, which does not seem to exist, maybe an old name for log_batchinsert.

By the docs, the sample script should call log_write_batch and not the other 2 loggers, but it calls them and not log_write_batch.

See PHP test file tests/mongos/stream-logger-001.phpt

Test script:
function log_batchinsert (array $server, array $docs, array $info, array $options) { 
  echo "Batch Insert " . count($docs) . " documents.\n"; 
function log_write_batch () { 
  echo __METHOD__ . "\n"; 
function log_query(array $server, array $criteria, array $queryOptions) { 
  echo "Query: " . json_encode($criteria) . "\n"; 

$context = stream_context_create([
  'mongodb' => ['log_batchinsert' => 'log_batchinsert', 'log_write_batch' => 'log_write_batch', 'log_query' => 'log_query'],
$server = 'mongodb://localhost:27017';
$client = new \MongoClient($server, [], ['context' => $context]);
$collection = $client->selectDB('bug')->selectCollection('bug_collection');
$docs = [['foo' => 'bar'], ['baz' => 'quux']];
$result = $collection->batchInsert($docs);

Expected result:

Actual result:
Query: {"drop":"bug_collection"}
Batch Insert 2 documents.
Query: {"getlasterror":1}


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-22 17:24 UTC] fgm at osinet dot fr
Just to be sure the issue is clear, I think the result from the code is just as it should, what needs to be fixed is the manpage.
 [2021-08-03 11:41 UTC]
-Package: mongo +Package: mongodb
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 25 09:01:29 2024 UTC