source: branches/comu-ver2/data/module/log4php/php4/log4php/appenders/LoggerAppenderPhp.php @ 18701

Revision 18701, 2.6 KB checked in by nanasess, 14 years ago (diff)

Copyright の更新(#601)

Line 
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 */
23if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..');
24 
25require_once(LOG4PHP_DIR . '/LoggerAppenderSkeleton.php');
26require_once(LOG4PHP_DIR . '/LoggerLevel.php');
27require_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 */
42class 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?>
Note: See TracBrowser for help on using the repository browser.