source: branches/comu-ver2/data/module/log4php/php4/log4php/spi/LoggerFilter.php @ 18220

Revision 18220, 4.2 KB checked in by yokkuns, 15 years ago (diff)

#149 ロガークラス作成

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 spi
18 */
19
20/**
21 * @ignore
22 */
23if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..');
24 
25/**
26 */
27require_once(LOG4PHP_DIR . '/spi/LoggerLoggingEvent.php');
28
29
30/**
31 * The log event must be logged immediately without consulting with
32 * the remaining filters, if any, in the chain. 
33 */
34define('LOG4PHP_LOGGER_FILTER_ACCEPT',  1);
35
36/**
37 * This filter is neutral with respect to the log event. The
38 * remaining filters, if any, should be consulted for a final decision.
39 */
40define('LOG4PHP_LOGGER_FILTER_NEUTRAL', 0);
41
42/**
43 * The log event must be dropped immediately without consulting
44 *  with the remaining filters, if any, in the chain. 
45 */
46define('LOG4PHP_LOGGER_FILTER_DENY',    -1);
47
48/**
49 * Users should extend this class to implement customized logging
50 * event filtering. Note that {@link LoggerCategory} and {@link LoggerAppenderSkeleton},
51 * the parent class of all standard
52 * appenders, have built-in filtering rules. It is suggested that you
53 * first use and understand the built-in rules before rushing to write
54 * your own custom filters.
55 *
56 * <p>This abstract class assumes and also imposes that filters be
57 * organized in a linear chain. The {@link #decide
58 * decide(LoggerLoggingEvent)} method of each filter is called sequentially,
59 * in the order of their addition to the chain.
60 *
61 * <p>The {@link decide()} method must return one
62 * of the integer constants {@link LOG4PHP_LOG4PHP_LOGGER_FILTER_DENY},
63 * {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} or {@link LOG4PHP_LOGGER_FILTER_ACCEPT}.
64 *
65 * <p>If the value {@link LOG4PHP_LOGGER_FILTER_DENY} is returned, then the log event is
66 * dropped immediately without consulting with the remaining
67 * filters.
68 *
69 * <p>If the value {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} is returned, then the next filter
70 * in the chain is consulted. If there are no more filters in the
71 * chain, then the log event is logged. Thus, in the presence of no
72 * filters, the default behaviour is to log all logging events.
73 *
74 * <p>If the value {@link LOG4PHP_LOGGER_FILTER_ACCEPT} is returned, then the log
75 * event is logged without consulting the remaining filters.
76 *
77 * <p>The philosophy of log4php filters is largely inspired from the
78 * Linux ipchains.
79 *
80 * @author VxR <vxr@vxr.it>
81 * @version $Revision: 1.3 $
82 * @package log4php
83 * @subpackage spi
84 */
85class LoggerFilter {
86
87    /**
88     * @var LoggerFilter Points to the next {@link LoggerFilter} in the filter chain.
89     */
90    var $next;
91
92    /**
93     * Usually filters options become active when set. We provide a
94     * default do-nothing implementation for convenience.
95    */
96    function activateOptions()
97    {
98        return;
99    }
100
101    /**   
102     * Decide what to do. 
103     * <p>If the decision is {@link LOG4PHP_LOGGER_FILTER_DENY}, then the event will be
104     * dropped. If the decision is {@link LOG4PHP_LOGGER_FILTER_NEUTRAL}, then the next
105     * filter, if any, will be invoked. If the decision is {@link LOG4PHP_LOGGER_FILTER_ACCEPT} then
106     * the event will be logged without consulting with other filters in
107     * the chain.
108     *
109     * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon.
110     * @return integer {@link LOG4PHP_LOGGER_FILTER_NEUTRAL} or {@link LOG4PHP_LOGGER_FILTER_DENY}|{@link LOG4PHP_LOGGER_FILTER_ACCEPT}
111     */
112    function decide($event)
113    {
114        return LOG4PHP_LOGGER_FILTER_NEUTRAL;
115    }
116
117}
118?>
Note: See TracBrowser for help on using the repository browser.