[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/log4php/appenders/ -> LoggerAppenderPhp.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 appenders
  18   */
  19  
  20  /**
  21   * @ignore 
  22   */
  23  if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..');
  24   
  25  require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php');
  26  require_once (LOG4PHP_DIR . '/LoggerLevel.php');
  27  require_once (LOG4PHP_DIR . '/LoggerLog.php');
  28  
  29  /**
  30   * Log events using php {@link PHP_MANUAL#trigger_error} function and a {@link LoggerLayoutTTCC} default layout.
  31   *
  32   * <p>Levels are mapped as follows:</p>
  33   * - <b>level &lt; WARN</b> mapped to E_USER_NOTICE
  34   * - <b>WARN &lt;= level &lt; ERROR</b> mapped to E_USER_WARNING
  35   * - <b>level &gt;= ERROR</b> mapped to E_USER_ERROR  
  36   *
  37   * @author VxR <vxr@vxr.it>
  38   * @version $Revision: 1.11 $
  39   * @package log4php
  40   * @subpackage appenders
  41   */ 
  42  class LoggerAppenderPhp extends LoggerAppenderSkeleton {
  43  
  44      /**
  45       * @access private
  46       */
  47      var $requiresLayout = false;
  48      
  49      /**
  50       * Constructor
  51       *
  52       * @param string $name appender name
  53       */
  54      function LoggerAppenderPhp($name)
  55      {
  56          $this->LoggerAppenderSkeleton($name);
  57      }
  58  
  59      function activateOptions()
  60      {
  61          $this->layout = LoggerLayout::factory('LoggerLayoutTTCC');
  62          $this->closed = false;
  63      }
  64  
  65      function close() 
  66      {
  67          $this->closed = true;
  68      }
  69  
  70      function append($event)
  71      {
  72          if ($this->layout !== null) {
  73              LoggerLog::debug("LoggerAppenderPhp::append()");
  74              $level = $event->getLevel();
  75              if ($level->isGreaterOrEqual(LoggerLevel::getLevelError())) {
  76                  trigger_error($this->layout->format($event), E_USER_ERROR);
  77              } elseif ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) {
  78                  trigger_error($this->layout->format($event), E_USER_WARNING);
  79              } else {
  80                  trigger_error($this->layout->format($event), E_USER_NOTICE);
  81              }
  82          }
  83      }
  84  }
  85  ?>


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