Changeset 22656
- Timestamp:
- 09/30/09 23:02:38 (4 years ago)
- Files:
-
- plugins/tmApacheLogParserPlugin/lib/tmApacheLogParser.class.php (modified) (1 diff)
- plugins/tmApacheLogParserPlugin/lib/tmApacheLogParserException.class.php (modified) (1 diff)
- plugins/tmApacheLogParserPlugin/lib/tmLineParser.class.php (modified) (4 diffs)
- plugins/tmApacheLogParserPlugin/package.xml (modified) (2 diffs)
- plugins/tmApacheLogParserPlugin/test/unit/test5.php (added)
- plugins/tmApacheLogParserPlugin/test/unit/test6.log (added)
- plugins/tmApacheLogParserPlugin/test/unit/test6.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/tmApacheLogParserPlugin/lib/tmApacheLogParser.class.php
r21799 r22656 36 36 { 37 37 return $this->lineParser->parse($line); 38 } 39 40 41 /** 42 * Returns a regular expression that is used to parse each line. 43 * 44 * @return string 45 */ 46 public function getRE() 47 { 48 return $this->lineParser->getRE(); 38 49 } 39 50 plugins/tmApacheLogParserPlugin/lib/tmApacheLogParserException.class.php
r21764 r22656 1 1 <?php 2 2 class tmApacheLogParserException extends Exception { 3 public static $INVALID_ARGUMENT = 1; 3 4 } plugins/tmApacheLogParserPlugin/lib/tmLineParser.class.php
r22650 r22656 7 7 public function __construct($re, $params) 8 8 { 9 10 if(! is_array($params) || !count($re) || !count($params)) { 11 throw new tmApacheLogParserException("You must provide arrays to the constructor",tmApacheLogParserException::$INVALID_ARGUMENT); 12 } 13 9 14 $all = array ( 10 15 'remote_ip' => array ( … … 60 65 } 61 66 $this->re = vsprintf($re, $reParams); 67 68 if(! $this->re) { 69 throw new tmApacheLogParserException("Invalid argument(s)",tmApacheLogParserException::$INVALID_ARGUMENT); 70 } 62 71 } 63 72 … … 66 75 $matches = array (); 67 76 $ret = preg_match('/' . $this->re . '/', $line, $matches); 68 77 69 78 if(! $ret) { 70 79 //ok, we didn't match the line - that's too bad! … … 79 88 $result[$element['name']] = $element['parser']->parse($matches[$i ++]); 80 89 } 81 90 82 91 return $result; 83 92 } 93 94 /** 95 * Returns a regular expression that is used to parse each line. 96 * 97 * @return string 98 */ 99 public function getRE() 100 { 101 return '/' . $this->re . '/'; 102 } 84 103 } plugins/tmApacheLogParserPlugin/package.xml
r21800 r22656 37 37 <file name="test/unit/test2.php" role="data"/> 38 38 <file name="test/unit/test3.php" role="data"/> 39 <file name="test/unit/test4.php" role="data"/> 40 <file name="test/unit/test5.php" role="data"/> 41 <file name="test/unit/test6.php" role="data"/> 39 42 </dir> 40 43 </contents> … … 61 64 <release> 62 65 <version> 63 <release>0.1. 0</release>64 <api>0.1. 0</api>66 <release>0.1.5</release> 67 <api>0.1.5</api> 65 68 </version> 66 69 <stability>