public function testLog2() { MongoLog::setLevel(MongoLog::NONE); MongoLog::setModule(MongoLog::NONE); $this->object->foo->bar->insert(array("x" => 1)); // this should be fine }
/** * * 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) { }
public function testModule() { \MongoLog::setModule(2); $this->assertSame(2, \MongoLog::getModule(2)); }
<?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));