_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"); } } }