Exemplo n.º 1
0
 /**
  * Close the stream resource.
  *
  * @return void
  */
 public function shutdown()
 {
     try {
         $this->_writeRepeated();
     } catch (Zend_Log_Exception $e) {
         // No problem if it should fail, don't want to break the program
     }
     // Close the file
     parent::shutdown();
 }
Exemplo n.º 2
0
 public static function toLog($message, $level = Zend_Log::INFO, $file = 'system_log.txt')
 {
     $filename = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getCorePath(), 'userdata', 'logs', $file));
     if (is_file($filename) == false) {
         return false;
     }
     if (is_writable($filename) == false) {
         return false;
     }
     try {
         $stream = new Zend_Log_Writer_Stream($filename);
         $logger = new RM_Log($stream);
         $logger->log($message, $level);
         $stream->shutdown();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Exemplo n.º 3
0
 public function testShutdownClosesStreamResource()
 {
     $writer = new Zend_Log_Writer_Stream('php://memory', 'w+');
     $writer->write(array('message' => 'this write should succeed'));
     $writer->shutdown();
     try {
         $writer->write(array('message' => 'this write should fail'));
         $this->fail();
     } catch (Exception $e) {
         $this->assertTrue($e instanceof Zend_Log_Exception);
         $this->assertRegExp('/unable to write/i', $e->getMessage());
     }
 }