<?php /* * $Id: Abstract.php 3155 2007-11-14 13:13:23Z jwage $ * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals * and is licensed under the LGPL. For more information, see * <http://www.phpdoctrine.com>. */ /** * @package Doctrine * @subpackage Log * @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Jonathan H. Wage <jwage@mac.com> * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.com * @since 1.0 * @version $Revision: 3155 $ */ abstract class Doctrine_Log_Writer_Abstract { /** * @var array of Doctrine_Log_Filter_Interface */ protected $_filters = array(); /** * Formats the log message before writing. * @var Doctrine_Log_Formatter_Interface */ protected $_formatter; /** * Add a filter specific to this writer. * * @param Doctrine_Log_Filter_Interface $filter * @return void */ public function addFilter($filter) { if (is_integer($filter)) { $filter = new Doctrine_Log_Filter_Priority($filter); } $this->_filters[] = $filter; } /** * Log a message to this writer. * * @param array $event log data event * @return void */ public function write($event) { foreach ($this->_filters as $filter) { if (! $filter->accept($event)) { return; } } // exception occurs on error $this->_write($event); } /** * Set a new formatter for this writer * * @param Doctrine_Log_Formatter_Interface $formatter * @return void */ public function setFormatter($formatter) { $this->_formatter = $formatter; } /** * Perform shutdown activites such as closing open resources * * @return void */ public function shutdown() {} /** * Write a message to the log. * * @param array $event log data event * @return void */ abstract protected function _write($event); }