Пример #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;
 }
Пример #3
0
 /**
  * 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.
  *
  * @link http://php.net/manual/en/mongolog.setmodule.php
  * @static
  * @param int $module The module(s) you would like to log
  * @return void
  */
 public static function setModule($module)
 {
     self::$module = $module;
 }
<?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) {
}
Пример #5
0
 public function testModule()
 {
     \MongoLog::setModule(2);
     $this->assertSame(2, \MongoLog::getModule(2));
 }
Пример #6
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));