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">
  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: 1213283 $
  • since: 0.3

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

LoggerConfigurable
   |
   --LoggerFilter
      |
      --LoggerFilterStringMatch
Variable Summary
Method Summary
integer decide (LoggerLoggingEvent $event)
void setAcceptOnMatch (mixed $acceptOnMatch)
void setStringToMatch ( $string, string $s)
Variables
boolean $acceptOnMatch = true (line 53)
  • access: protected
string $stringToMatch (line 58)
  • access: protected

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, string $s)
  • string $s: the string to match
  • $string

Inherited Methods

Inherited From LoggerFilter

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

Inherited From LoggerConfigurable

LoggerConfigurable::setBoolean()
LoggerConfigurable::setFileSize()
LoggerConfigurable::setInteger()
LoggerConfigurable::setLevel()
LoggerConfigurable::setNumeric()
LoggerConfigurable::setPositiveInteger()
LoggerConfigurable::setString()
LoggerConfigurable::warn()
Class Constants

Documentation generated on Sat, 18 Feb 2012 22:32:24 +0000 by phpDocumentor 1.4.3