From 5b114249ceba411d407cf38142945edd1e9e8f9f Mon Sep 17 00:00:00 2001 From: theli Date: Sat, 14 Oct 2006 13:21:07 +0000 Subject: [PATCH] *) Bugfix for ViewLog problem with multiline logging messages See: http://www.yacy-forum.de/viewtopic.php?t=2972 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2774 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ViewLog_p.java | 19 +++++++++++++++++-- .../de/anomic/server/logging/GuiHandler.java | 2 -- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/htroot/ViewLog_p.java b/htroot/ViewLog_p.java index 050a28ea6..74b803c7f 100644 --- a/htroot/ViewLog_p.java +++ b/htroot/ViewLog_p.java @@ -48,6 +48,8 @@ import java.util.logging.Handler; import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import de.anomic.http.httpHeader; @@ -62,7 +64,7 @@ public class ViewLog_p { String[] log = new String[0]; boolean reversed = false; int lines = 200; - String filter = ".*.*"; + String filter = ".*"; if(post != null){ if(post.containsKey("mode") && ((String)post.get("mode")).equals("reversed")){ @@ -90,12 +92,25 @@ public class ViewLog_p { prop.put("lines", lines); prop.put("filter", filter); + // trying to compile the regular expression filter expression + Matcher filterMatcher = null; + try { + Pattern filterPattern = Pattern.compile(filter,Pattern.MULTILINE); + filterMatcher = filterPattern.matcher(""); + } catch (PatternSyntaxException e) { + e.printStackTrace(); + } + int level = 0; int lc = 0; for (int i=0; i < log.length; i++) { String nextLogLine = log[i].trim(); - try {if (!(nextLogLine.matches(filter))) continue;} catch (PatternSyntaxException e) {} + + if (filterMatcher != null) { + filterMatcher.reset(nextLogLine); + if (!filterMatcher.find()) continue; + } if (nextLogLine.startsWith("E ")) level = 4; else if (nextLogLine.startsWith("W ")) level = 3; diff --git a/source/de/anomic/server/logging/GuiHandler.java b/source/de/anomic/server/logging/GuiHandler.java index 9fc150995..00c50d8b0 100644 --- a/source/de/anomic/server/logging/GuiHandler.java +++ b/source/de/anomic/server/logging/GuiHandler.java @@ -193,8 +193,6 @@ public class GuiHandler extends Handler{ if ((lineCount > this.count)||(lineCount < 0)) lineCount = this.count; ArrayList logMessages = new ArrayList(this.count); - logMessages.add("Testmessage:\r\nline1\r\nline2"); - Formatter logFormatter = getFormatter(); try {