cvs: pear /Log_Parser/Parser Config_Namespace.php Filter_Engine.php

From: Date: Wed, 24 Sep 2003 15:11:19 +0000
Subject: cvs: pear /Log_Parser/Parser Config_Namespace.php Filter_Engine.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-13058@lists.php.net to get a copy of this message
xnoguer Wed Sep 24 11:11:19 2003 EDT Added files: /pear/Log_Parser/Parser Filter_Engine.php Modified files: /pear/Log_Parser/Parser Config_Namespace.php Log: commiting for toby Index: pear/Log_Parser/Parser/Config_Namespace.php diff -u pear/Log_Parser/Parser/Config_Namespace.php:1.1 pear/Log_Parser/Parser/Config_Namespace.php:1.2 --- pear/Log_Parser/Parser/Config_Namespace.php:1.1 Mon May 19 19:16:09 2003 +++ pear/Log_Parser/Parser/Config_Namespace.php Wed Sep 24 11:11:18 2003 @@ -16,7 +16,7 @@ // | Authors: | // +----------------------------------------------------------------------+ // -// $Id: Config_Namespace.php,v 1.1 2003/05/19 23:16:09 pajoye Exp $ +// $Id: Config_Namespace.php,v 1.2 2003/09/24 15:11:18 xnoguer Exp $ require_once 'PEAR.php'; require_once 'XML/Transformer/Namespace.php'; @@ -41,7 +41,7 @@ var $_typeLookUp; var $error; - + function &getLines ( ) { return $this->lines; @@ -54,6 +54,7 @@ } else { $this->logname = LOG_PARSER_STANDARD_LOGNAME; } + return ""; } @@ -72,7 +73,9 @@ $this->error = $this->raiseError("Line double-definition for line ".$att['name'], 2); return false; } + $this->lines[$att['name']] = Array(); + $this->lastLine = $att['name']; return ""; } @@ -92,8 +95,9 @@ $this->lines[$this->lastLine][$att['id']] = Array(); if (isset($att['pattern'])) { $this->lines[$this->lastLine][$att['id']]['pattern'] = $att['pattern']; - } else if (isset($att['type'])) { - $this->lines[$this->lastLine][$att['id']]['tpye'] = $att['type']; + } + if (isset($att['type'])) { + $this->lines[$this->lastLine][$att['id']]['type'] = $att['type']; $pattern = $this->_patternLookUp($att['type']); if (!$pattern) { return false; @@ -112,7 +116,7 @@ function _patternLookUp ( $type ) { if (!isset($this->_patternLookUp)) { - require_once 'patter_lookup.inc.php'; + require_once 'Log_Parser/data/patter_lookup.inc.php'; $this->_patternLookUp = $pattern_type; } if (!isset($this->_patternLookUp[$type])) { Index: pear/Log_Parser/Parser/Filter_Engine.php +++ pear/Log_Parser/Parser/Filter_Engine.php <?php require_once 'PEAR.php'; require_once 'Log_Parser/Parser/Filter/Filter.php'; /** * PEAR::Log_Parser::Filter_Engine * * This is the filter engine to drive PEAR::Log_Parser::Filter objects * * @author Tobias Schlitt <toby@php.net> * @package Log_Parser * @version $Revision: 1.1 $ */ class Log_Parser_Filter_Engine { /** * The filter object which performs the filtering. * * @access private * @var object Log_Parser_Filter_Dynamic or Log_Parser_Filter_Static */ var $_filterObject; /** * The type of filter used (dynamic or static) * * @access private * @var string */ var $_filterType; /** * A PEAR::Error object, if an error occured. Accessable through * Log_Parser_Filter_Engin::getError(). * * @access private * @var object PEAR::Error */ var $_error; /** * Constructor * This generates a new Filter_Engine with a given filter object. The object * has to inherit either Log_Parser_Filter_Static or Log_Parser_Filter_Dynamic. * * @access public * @param object $filterObject A filter object as described above * @returns void */ function Log_Parser_Filter_Engine ( &$filterObject ) { if (is_subclass_of($filterObject, 'Log_Parser_Filter_Dynamic')) { $this->_filterObject =& $filterObject; $this->_filterType = LOG_PARSER_FILTER_DYNAMIC; } if (is_subclass_of($filterObject, 'Log_Parser_Filter_Static')) { $this->_filterObject =& $filterObject; $this->_filterType = LOG_PARSER_FILTER_STATIC; } if (!isset($this->_filterType)) { $this->_error = PEAR::raiseError('Object is not a valid filter object', 0); } } /** * Main filtering function * This does the filtering functionality * * @access public * @param string $lineName The name of the line to filter * @param array $line The line to filter (as ready parsed array) * @returns bool True if the line passed filtering, otherwise false */ function filter ( $lineName, &$line ) { switch ($this->_filterType) { case LOG_PARSER_FILTER_STATIC: foreach ( $line as $tokenName => $token ) { if (!$this->_filterObject->filter( $lineName, $tokenName, $line[$tokenName] )) { return false; } } break; case LOG_PARSER_FILTER_DYNAMIC: foreach ( $line as $tokenName => $token ) { $methodName = $lineName . '_' . $tokenName; if (method_exists($this->_filterObject, $methodName)) { if (!$this->_filterObject->$methodName(&$line[$tokenName])) { return false; } } } default: $this->error = PEAR::raiseError('Could not filter token', 0); break; } return true; } /** * Return the last occured error * This method returns the last occured error happened * * @access public * @returns object PEAR::Error if an error occured, otherwise void */ function &getError ( ) { return $this->_error; } /** * Check if an error has occured * This method checks if an error has occured in the engine * * @access public * @return bool True if an error occured, otherwise false */ function hasError ( ) { if (PEAR::isError($this->_error)) { return true; } else { return false; } } } ?>

« previous php.pear.cvs (#13058) next »