setModule() public static method

This function can be used to set which parts of the driver's functionality should be logged. Use the constants described in the MongoLog section with bitwise operators to specify modules.
public static setModule ( integer $module ) : void
$module integer The module(s) you would like to log
return void
示例#1
0
 public function testLog2()
 {
     MongoLog::setLevel(MongoLog::NONE);
     MongoLog::setModule(MongoLog::NONE);
     $this->object->foo->bar->insert(array("x" => 1));
     // this should be fine
 }
示例#2
0
 /**
  *
  * Note: problem connecting mongoDB will throw MongoConnectionException
  * @return MongoDB
  * @throws MongoConnectionException
  */
 public function getMongoDB($force = false)
 {
     if (\Config::$DEBUG) {
         error_reporting(E_ALL);
         // print every log message possible
         if (\Config::$DEBUG == 10) {
             \MongoLog::setLevel(\MongoLog::ALL);
             // all log levels
             \MongoLog::setModule(\MongoLog::ALL);
             // all parts of the driver
         }
     }
     if (is_null($this->mongo) || is_null($this->mongoDB) || $force) {
         $this->mongo = new \MongoClient();
         // connect
         $this->mongoDB = $this->mongo->selectDB(\Config::$MONGODB_DATABASE);
     }
     return $this->mongoDB;
 }
<?php

MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::ALL);
echo "First one\n";
try {
    $m = new Mongo("mongodb:///tmp/mongodb-27017.sock/?replicaSet=foo", array("connect" => 0));
} catch (Exception $e) {
}
echo "\nSecond one\n";
try {
    $m = new Mongo("mongodb:///tmp/mongodb-27017.sock/databasename?replicaSet=foo", array("connect" => 0));
} catch (Exception $e) {
}
echo "\nThird one\n";
try {
    $m = new Mongo("mongodb:///tmp/mongodb-27017.sock", array("connect" => 0));
} catch (Exception $e) {
}
echo "\nForth one\n";
try {
    $m = new Mongo("mongodb:///tmp/mongodb-27017.sock/databasename", array("connect" => 0));
} catch (Exception $e) {
}
示例#4
0
 public function testModule()
 {
     \MongoLog::setModule(2);
     $this->assertSame(2, \MongoLog::getModule(2));
 }
示例#5
0
<?php

require_once __DIR__ . "/../utils/server.inc";
MongoLog::setModule(MongoLog::PARSE);
MongoLog::setLevel(MongoLog::INFO);
set_error_handler('foo');
function foo($a, $b, $c)
{
    echo $b, "\n";
}
new MongoClient("mongodb://localhost", array('connect' => false));
new MongoClient("mongodb://localhost/", array('connect' => false));
new MongoClient("mongodb://localhost/x", array('connect' => false));
new MongoClient("mongodb://localhost/?readPreference=PRIMARY", array('connect' => false));