Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

*) Bugfix for ViewLog problem with multiline logging messages See: http://www.yacy-forum.de/viewtopic.php?t=2972

theli5b114249ceba
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 {