• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Zend/Log/Writer/Stream.php

00001 <?php
00024 require_once 'Zend/Log/Writer/Abstract.php';
00025 
00027 require_once 'Zend/Log/Formatter/Simple.php';
00028 
00037 class Zend_Log_Writer_Stream extends Zend_Log_Writer_Abstract
00038 {
00043     protected $_stream = null;
00044 
00051     public function __construct($streamOrUrl, $mode = 'a')
00052     {
00053         if (is_resource($streamOrUrl)) {
00054             if (get_resource_type($streamOrUrl) != 'stream') {
00055                 require_once 'Zend/Log/Exception.php';
00056                 throw new Zend_Log_Exception('Resource is not a stream');
00057             }
00058 
00059             if ($mode != 'a') {
00060                 require_once 'Zend/Log/Exception.php';
00061                 throw new Zend_Log_Exception('Mode cannot be changed on existing streams');
00062             }
00063 
00064             $this->_stream = $streamOrUrl;
00065         } else {
00066             if (! $this->_stream = @fopen($streamOrUrl, $mode, false)) {
00067                 require_once 'Zend/Log/Exception.php';
00068                 $msg = "\"$streamOrUrl\" cannot be opened with mode \"$mode\"";
00069                 throw new Zend_Log_Exception($msg);
00070             }
00071         }
00072 
00073         $this->_formatter = new Zend_Log_Formatter_Simple();
00074     }
00075 
00081     public function shutdown()
00082     {
00083         if (is_resource($this->_stream)) {
00084             fclose($this->_stream);
00085         }
00086     }
00087 
00094     protected function _write($event)
00095     {
00096         $line = $this->_formatter->format($event);
00097 
00098         if (false === @fwrite($this->_stream, $line)) {
00099             require_once 'Zend/Log/Exception.php';
00100             throw new Zend_Log_Exception("Unable to write to stream");
00101         }
00102     }
00103 
00104 }

Generated on Thu Apr 19 2012 17:01:18 for openbiz by  doxygen 1.7.2