mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
29f375a679
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92549 467b73ca-7a2a-4603-9d3b-597d59a354a9
107 lines
2.6 KiB
PHP
107 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* Zend Framework
|
|
*
|
|
* LICENSE
|
|
*
|
|
* This source file is subject to the new BSD license that is bundled
|
|
* with this package in the file LICENSE.txt.
|
|
* It is also available through the world-wide-web at this URL:
|
|
* http://framework.zend.com/license/new-bsd
|
|
* If you did not receive a copy of the license and are unable to
|
|
* obtain it through the world-wide-web, please send an email
|
|
* to license@zend.com so we can send you a copy immediately.
|
|
*
|
|
* @category Zend
|
|
* @package Zend_Log
|
|
* @subpackage Writer
|
|
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
* @version $Id: Abstract.php 13621 2009-01-14 01:53:04Z cadorn $
|
|
*/
|
|
|
|
/** Zend_Log_Filter_Priority */
|
|
require_once 'Zend/Log/Filter/Priority.php';
|
|
|
|
/**
|
|
* @category Zend
|
|
* @package Zend_Log
|
|
* @subpackage Writer
|
|
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
* @version $Id: Abstract.php 13621 2009-01-14 01:53:04Z cadorn $
|
|
*/
|
|
abstract class Zend_Log_Writer_Abstract
|
|
{
|
|
/**
|
|
* @var array of Zend_Log_Filter_Interface
|
|
*/
|
|
protected $_filters = array();
|
|
|
|
/**
|
|
* Formats the log message before writing.
|
|
* @var Zend_Log_Formatter_Interface
|
|
*/
|
|
protected $_formatter;
|
|
|
|
/**
|
|
* Add a filter specific to this writer.
|
|
*
|
|
* @param Zend_Log_Filter_Interface $filter
|
|
* @return void
|
|
*/
|
|
public function addFilter($filter)
|
|
{
|
|
if (is_integer($filter)) {
|
|
$filter = new Zend_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 Zend_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);
|
|
|
|
} |