Microsoft_Log
[ class tree: Microsoft_Log ] [ index: Microsoft_Log ] [ all elements ]

Source for file Message.php

Documentation is available at Message.php

  1. <?php
  2. /**
  3.  * Zend Framework
  4.  *
  5.  * LICENSE
  6.  *
  7.  * This source file is subject to the new BSD license that is bundled
  8.  * with this package in the file LICENSE.txt.
  9.  * It is also available through the world-wide-web at this URL:
  10.  * http://framework.zend.com/license/new-bsd
  11.  * If you did not receive a copy of the license and are unable to
  12.  * obtain it through the world-wide-web, please send an email
  13.  * to license@zend.com so we can send you a copy immediately.
  14.  *
  15.  * @category   Microsoft
  16.  * @package    Microsoft_Log
  17.  * @subpackage Filter
  18.  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19.  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  20.  * @version    $Id: Message.php 20982 2010-02-08 15:51:36Z matthew $
  21.  */
  22.  
  23. /**
  24.  * @see Microsoft_AutoLoader
  25.  */
  26. require_once dirname(__FILE__'/../../AutoLoader.php';
  27.  
  28. /**
  29.  * @category   Microsoft
  30.  * @package    Microsoft_Log
  31.  * @subpackage Filter
  32.  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  33.  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  34.  * @version    $Id: Message.php 20982 2010-02-08 15:51:36Z matthew $
  35.  */
  36. {
  37.     /**
  38.      * @var string 
  39.      */
  40.     protected $_regexp;
  41.  
  42.     /**
  43.      * Filter out any log messages not matching $regexp.
  44.      *
  45.      * @param  string  $regexp     Regular expression to test the log message
  46.      * @throws Microsoft_Log_Exception
  47.      */
  48.     public function __construct($regexp)
  49.     {
  50.         if (@preg_match($regexp''=== false{
  51.             require_once 'Microsoft/Log/Exception.php';
  52.             throw new Microsoft_Log_Exception("Invalid regular expression '$regexp'");
  53.         }
  54.         $this->_regexp = $regexp;
  55.     }
  56.  
  57.     /**
  58.      * Create a new instance of Microsoft_Log_Filter_Message
  59.      * 
  60.      * @param  array $config 
  61.      * @return Microsoft_Log_Filter_Message 
  62.      * @throws Microsoft_Log_Exception
  63.      */
  64.     static public function factory($config
  65.     {
  66.         $config self::_parseConfig($config);
  67.         $config array_merge(array(
  68.             'regexp' => null
  69.         )$config);
  70.  
  71.         return new self(
  72.             $config['regexp']
  73.         );
  74.     }
  75.  
  76.     /**
  77.      * Returns TRUE to accept the message, FALSE to block it.
  78.      *
  79.      * @param  array    $event    event data
  80.      * @return boolean            accepted?
  81.      */
  82.     public function accept($event)
  83.     {
  84.         return preg_match($this->_regexp$event['message']0;
  85.     }
  86. }

Documentation generated on Wed, 18 May 2011 12:06:41 +0200 by phpDocumentor 1.4.3