web/lib/Zend/Log/Writer/Abstract.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Log
    16  * @package    Zend_Log
    17  * @subpackage Writer
    17  * @subpackage Writer
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: Abstract.php 22567 2010-07-16 03:32:31Z ramon $
    20  * @version    $Id: Abstract.php 24593 2012-01-05 20:35:02Z matthew $
    21  */
    21  */
    22 
    22 
    23 /** Zend_Log_Filter_Priority */
    23 /** Zend_Log_Filter_Priority */
    24 require_once 'Zend/Log/Filter/Priority.php';
    24 require_once 'Zend/Log/Filter/Priority.php';
    25 
    25 
    26 /**
    26 /**
    27  * @category   Zend
    27  * @category   Zend
    28  * @package    Zend_Log
    28  * @package    Zend_Log
    29  * @subpackage Writer
    29  * @subpackage Writer
    30  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    30  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    32  * @version    $Id: Abstract.php 22567 2010-07-16 03:32:31Z ramon $
    32  * @version    $Id: Abstract.php 24593 2012-01-05 20:35:02Z matthew $
    33  */
    33  */
    34 abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface
    34 abstract class Zend_Log_Writer_Abstract implements Zend_Log_FactoryInterface
    35 {
    35 {
    36     /**
    36     /**
    37      * @var array of Zend_Log_Filter_Interface
    37      * @var array of Zend_Log_Filter_Interface
    38      */
    38      */
    39     protected $_filters = array();
    39     protected $_filters = array();
    40 
    40 
    41     /**
    41     /**
    42      * Formats the log message before writing.
    42      * Formats the log message before writing.
       
    43      *
    43      * @var Zend_Log_Formatter_Interface
    44      * @var Zend_Log_Formatter_Interface
    44      */
    45      */
    45     protected $_formatter;
    46     protected $_formatter;
    46 
    47 
    47     /**
    48     /**
    48      * Add a filter specific to this writer.
    49      * Add a filter specific to this writer.
    49      *
    50      *
    50      * @param  Zend_Log_Filter_Interface  $filter
    51      * @param  Zend_Log_Filter_Interface  $filter
    51      * @return void
    52      * @return Zend_Log_Writer_Abstract
    52      */
    53      */
    53     public function addFilter($filter)
    54     public function addFilter($filter)
    54     {
    55     {
    55         if (is_integer($filter)) {
    56         if (is_int($filter)) {
    56             $filter = new Zend_Log_Filter_Priority($filter);
    57             $filter = new Zend_Log_Filter_Priority($filter);
    57         }
    58         }
    58 
    59 
    59         if (!$filter instanceof Zend_Log_Filter_Interface) {
    60         if (!$filter instanceof Zend_Log_Filter_Interface) {
    60             /** @see Zend_Log_Exception */
    61             /** @see Zend_Log_Exception */
    67     }
    68     }
    68 
    69 
    69     /**
    70     /**
    70      * Log a message to this writer.
    71      * Log a message to this writer.
    71      *
    72      *
    72      * @param  array     $event  log data event
    73      * @param  array $event log data event
    73      * @return void
    74      * @return void
    74      */
    75      */
    75     public function write($event)
    76     public function write($event)
    76     {
    77     {
    77         foreach ($this->_filters as $filter) {
    78         foreach ($this->_filters as $filter) {
    86 
    87 
    87     /**
    88     /**
    88      * Set a new formatter for this writer
    89      * Set a new formatter for this writer
    89      *
    90      *
    90      * @param  Zend_Log_Formatter_Interface $formatter
    91      * @param  Zend_Log_Formatter_Interface $formatter
    91      * @return void
    92      * @return Zend_Log_Writer_Abstract
    92      */
    93      */
    93     public function setFormatter(Zend_Log_Formatter_Interface $formatter)
    94     public function setFormatter(Zend_Log_Formatter_Interface $formatter)
    94     {
    95     {
    95         $this->_formatter = $formatter;
    96         $this->_formatter = $formatter;
    96         return $this;
    97         return $this;
   126         }
   127         }
   127 
   128 
   128         if (!is_array($config)) {
   129         if (!is_array($config)) {
   129             require_once 'Zend/Log/Exception.php';
   130             require_once 'Zend/Log/Exception.php';
   130             throw new Zend_Log_Exception(
   131             throw new Zend_Log_Exception(
   131 				'Configuration must be an array or instance of Zend_Config'
   132                 'Configuration must be an array or instance of Zend_Config'
   132 			);
   133             );
   133         }
   134         }
   134 
   135 
   135         return $config;
   136         return $config;
   136     }
   137     }
   137 }
   138 }