Class LoggerFilterStringMatch

Description

This is a very simple filter based on string matching.

The filter admits two options $stringToMatch and $acceptOnMatch. If there is a match (using http://www.php.net/strpos between the value of the $stringToMatch option and the message of the LoggerLoggingEvent, then the decide() method returns LoggerFilter::ACCEPT if the AcceptOnMatch option value is true, if it is false then LoggerFilter::DENY is returned. If there is no match, LoggerFilter::NEUTRAL is returned.

An example for this filter:

  1. require_once dirname(__FILE__).'/../../main/php/Logger.php';
  2.  
  3. Logger::configure(dirname(__FILE__).'/../resources/filter_stringmatch.xml');
  4. $logger Logger::getRootLogger();
  5. $logger->debug("Some text to match that will be rejected");
  6. $logger->info("Some other text that will be accepted");

The corresponding XML file:

  1. <log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/" threshold="all" debug="false">
  2.     <appender name="default" class="LoggerAppenderEcho">
  3.         <layout class="LoggerLayoutTTCC"/>
  4.         <filter class="LoggerFilterStringMatch">
  5.             <param name="StringToMatch" value="match" />
  6.             <param name="AcceptOnMatch" value="false" />
  7.         </filter>
  8.     </appender>
  9.     <root>
  10.         <level value="DEBUG" />
  11.         <appender_ref ref="default" />
  12.     </root>
  13. </log4php:configuration>

  • version: $Revision: 883108 $
  • since: 0.3

Located in /filters/LoggerFilterStringMatch.php (line 48)

LoggerFilter
   |
   --LoggerFilterStringMatch
Method Summary
integer decide (LoggerLoggingEvent $event)
void setAcceptOnMatch (mixed $acceptOnMatch)
void setStringToMatch (string $s)
Variables

Inherited Variables

Inherited from LoggerFilter

LoggerFilter::$next
Methods
decide (line 77)
  • return: a LOGGER_FILTER_NEUTRAL is there is no string match.
  • access: public
integer decide (LoggerLoggingEvent $event)

Redefinition of:
LoggerFilter::decide()
Decide what to do.
setAcceptOnMatch (line 63)
  • access: public
void setAcceptOnMatch (mixed $acceptOnMatch)
  • mixed $acceptOnMatch: a boolean or a string ('true' or 'false')
setStringToMatch (line 70)
  • access: public
void setStringToMatch (string $s)
  • string $s: the string to match

Inherited Methods

Inherited From LoggerFilter

LoggerFilter::activateOptions()
LoggerFilter::addNext()
LoggerFilter::decide()
LoggerFilter::getNext()
Class Constants

Documentation generated on Fri, 27 Nov 2009 07:44:49 +0100 by phpDocumentor 1.4.3