Beispiel #1
0
 protected function _createLogWriter($dsn)
 {
     if (!is_object($dsn)) {
         $dsn = new lmbUri($dsn);
     }
     $writer_name = 'lmbLog' . ucfirst($dsn->getProtocol()) . 'Writer';
     $writer_file = 'limb/log/src/' . $writer_name . '.class.php';
     try {
         lmb_require($writer_file);
         $writer = new $writer_name($dsn);
         return $writer;
     } catch (lmbFileNotFoundException $e) {
         throw new lmbFileNotFoundException($writer_file, 'Log writer not found');
     }
 }
Beispiel #2
0
 function testCreate_FileProtocolWithHost()
 {
     $str = 'file://*****:*****@localhost/dir/file';
     $uri = new lmbUri($str);
     $this->assertEqual($uri->getProtocol(), 'file');
     $this->assertEqual($uri->getUser(), 'user');
     $this->assertEqual($uri->getPassword(), 'pass');
     $this->assertEqual($uri->getHost(), 'localhost');
     $this->assertEqual($uri->getPath(), '/dir/file');
     $str = 'file://*****:*****@localhost/c:\\dir\\file';
     $uri = new lmbUri($str);
     $this->assertEqual($uri->getProtocol(), 'file');
     $this->assertEqual($uri->getUser(), 'user');
     $this->assertEqual($uri->getPassword(), 'pass');
     $this->assertEqual($uri->getHost(), 'localhost');
     // should it be just c:\dir\file ???
     $this->assertEqual($uri->getPath(), '/c:\\dir\\file');
 }
 /**
  * @param string|lmbUri $dsn
  * @return lmbLogWriter
  */
 function createLogWriterByDSN($dsn)
 {
     if (!is_object($dsn)) {
         $dsn = new lmbUri($dsn);
     }
     if (!$dsn->getProtocol()) {
         throw new lmbException('Empty log writer type', array('dsn' => $dsn->toString()));
     }
     $writer_name = 'lmbLog' . ucfirst($dsn->getProtocol()) . 'Writer';
     $writer_file = 'limb/log/src/writers/' . $writer_name . '.class.php';
     try {
         lmb_require($writer_file);
         $writer = new $writer_name($dsn);
         return $writer;
     } catch (lmbFileNotFoundException $e) {
         throw new lmbFileNotFoundException($writer_file, 'Log writer not found');
     }
 }