[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/log4php/varia/ -> LoggerLevelMatchFilter.php (source)

   1  <?php
   2  /**
   3   * log4php is a PHP port of the log4j java logging package.
   4   * 
   5   * <p>This framework is based on log4j (see {@link http://jakarta.apache.org/log4j log4j} for details).</p>
   6   * <p>Design, strategies and part of the methods documentation are developed by log4j team 
   7   * (Ceki Gülcü as log4j project founder and 
   8   * {@link http://jakarta.apache.org/log4j/docs/contributors.html contributors}).</p>
   9   *
  10   * <p>PHP port, extensions and modifications by VxR. All rights reserved.<br>
  11   * For more information, please see {@link http://www.vxr.it/log4php/}.</p>
  12   *
  13   * <p>This software is published under the terms of the LGPL License
  14   * a copy of which has been included with this distribution in the LICENSE file.</p>
  15   * 
  16   * @package log4php
  17   * @subpackage varia
  18   */
  19  
  20  /**
  21   * @ignore 
  22   */
  23  if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..');
  24   
  25  /**
  26   */
  27  require_once (LOG4PHP_DIR . '/helpers/LoggerOptionConverter.php');
  28  require_once (LOG4PHP_DIR . '/spi/LoggerFilter.php');
  29  
  30  /**
  31   * This is a very simple filter based on level matching.
  32   *
  33   * <p>The filter admits two options <b><var>LevelToMatch</var></b> and
  34   * <b><var>AcceptOnMatch</var></b>. If there is an exact match between the value
  35   * of the <b><var>LevelToMatch</var></b> option and the level of the 
  36   * {@link LoggerLoggingEvent}, then the {@link decide()} method returns 
  37   * {@link LOG4PHP_LOGGER_FILTER_ACCEPT} in case the <b><var>AcceptOnMatch</var></b> 
  38   * option value is set to <i>true</i>, if it is <i>false</i> then 
  39   * {@link LOG4PHP_LOGGER_FILTER_DENY} is returned. If there is no match, 
  40   * {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} is returned.</p>
  41   *
  42   * @author VxR <vxr@vxr.it>
  43   * @version $Revision: 1.2 $
  44   * @package log4php
  45   * @subpackage varia
  46   * @since 0.6
  47   */
  48  class LoggerLevelMatchFilter extends LoggerFilter {
  49    
  50      /**
  51       * @var boolean
  52       */
  53      var $acceptOnMatch = true;
  54  
  55      /**
  56       * @var LoggerLevel
  57       */
  58      var $levelToMatch;
  59    
  60      /**
  61       * @return boolean
  62       */
  63      function getAcceptOnMatch()
  64      {
  65          return $this->acceptOnMatch;
  66      }
  67      
  68      /**
  69       * @param boolean $acceptOnMatch
  70       */
  71      function setAcceptOnMatch($acceptOnMatch)
  72      {
  73          $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); 
  74      }
  75      
  76      /**
  77       * @return LoggerLevel
  78       */
  79      function getLevelToMatch()
  80      {
  81          return $this->levelToMatch;
  82      }
  83      
  84      /**
  85       * @param string $l the level to match
  86       */
  87      function setLevelToMatch($l)
  88      {
  89          $this->levelToMatch = LoggerOptionConverter::toLevel($l, null);
  90      }
  91  
  92      /**
  93       * Return the decision of this filter.
  94       * 
  95       * Returns {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} if the <b><var>LevelToMatch</var></b>
  96       * option is not set or if there is not match.  Otherwise, if there is a
  97       * match, then the returned decision is {@link LOG4PHP_LOGGER_FILTER_ACCEPT} if the
  98       * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
  99       * returned decision is {@link LOG4PHP_LOGGER_FILTER_DENY} if the
 100       * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
 101       *
 102       * @param LoggerLoggingEvent $event
 103       * @return integer
 104       */
 105      function decide($event)
 106      {
 107          if($this->levelToMatch === null)
 108              return LOG4PHP_LOGGER_FILTER_NEUTRAL;
 109          
 110          if ($this->levelToMatch->equals($event->getLevel())) {  
 111              return $this->getAcceptOnMatch() ? 
 112                  LOG4PHP_LOGGER_FILTER_ACCEPT : 
 113                  LOG4PHP_LOGGER_FILTER_DENY;
 114          } else {
 115              return LOG4PHP_LOGGER_FILTER_NEUTRAL;
 116          }
 117      }
 118  }
 119  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7