diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Log/Writer/Stream.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Log/Writer/Stream.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,135 @@ +_stream = $streamOrUrl; + } else { + if (is_array($streamOrUrl) && isset($streamOrUrl['stream'])) { + $streamOrUrl = $streamOrUrl['stream']; + } + + if (! $this->_stream = @fopen($streamOrUrl, $mode, false)) { + require_once 'Zend/Log/Exception.php'; + $msg = "\"$streamOrUrl\" cannot be opened with mode \"$mode\""; + throw new Zend_Log_Exception($msg); + } + } + + $this->_formatter = new Zend_Log_Formatter_Simple(); + } + + /** + * Create a new instance of Zend_Log_Writer_Mock + * + * @param array|Zend_Config $config + * @return Zend_Log_Writer_Mock + * @throws Zend_Log_Exception + */ + static public function factory($config) + { + $config = self::_parseConfig($config); + $config = array_merge(array( + 'stream' => null, + 'mode' => null, + ), $config); + + $streamOrUrl = isset($config['url']) ? $config['url'] : $config['stream']; + + return new self( + $streamOrUrl, + $config['mode'] + ); + } + + /** + * Close the stream resource. + * + * @return void + */ + public function shutdown() + { + if (is_resource($this->_stream)) { + fclose($this->_stream); + } + } + + /** + * Write a message to the log. + * + * @param array $event event data + * @return void + */ + protected function _write($event) + { + $line = $this->_formatter->format($event); + + if (false === @fwrite($this->_stream, $line)) { + require_once 'Zend/Log/Exception.php'; + throw new Zend_Log_Exception("Unable to write to stream"); + } + } +}