Improved code.
This commit is contained in:
parent
4ee90a3671
commit
5e4829d315
1 changed files with 5 additions and 5 deletions
|
@ -222,13 +222,11 @@ public class HttpAccessLogAnalyzer
|
|||
* the line
|
||||
* @return the http log
|
||||
*/
|
||||
public static HttpAccessLog parseLog(final String line, final String pattern)
|
||||
public static HttpAccessLog parseLog(final String line, final Pattern pattern)
|
||||
{
|
||||
HttpAccessLog result;
|
||||
|
||||
Pattern combined = Pattern.compile(pattern);
|
||||
|
||||
Matcher matcher = combined.matcher(line);
|
||||
Matcher matcher = pattern.matcher(line);
|
||||
if (matcher.matches())
|
||||
{
|
||||
result = new HttpAccessLog();
|
||||
|
@ -266,7 +264,9 @@ public class HttpAccessLogAnalyzer
|
|||
// '"$http_referer" "$http_user_agent"';
|
||||
String combinedPattern = "^(?<remoteAddress>[a-zA-F0-9\\\\:\\\\.]+) - (?<remoteUser>\\S+) \\[(?<time>[^\\]]+)\\] \"(?<request>[^\"]*)\" (?<status>\\d+) (?<bodyBytesSent>\\d+) \"(?<referer>[^\"]*)\" \"(?<userAgent>[^\"]*)\".*$";
|
||||
|
||||
result = parseLog(line, combinedPattern);
|
||||
Pattern pattern = Pattern.compile(combinedPattern);
|
||||
|
||||
result = parseLog(line, pattern);
|
||||
|
||||
//
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue