reverted also changes in ViewLog from SVN 7557 because the ThreadDump submenu was not visible any more.
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7560 6c8d7289-2bf4-0310-a012-ef5d649a1542pull/1/head
parent
70a996a06c
commit
29acd2f108
@ -1,134 +1,124 @@
|
|||||||
//ViewLog_p.java
|
//ViewLog_p.java
|
||||||
//-----------------------
|
//-----------------------
|
||||||
//part of the AnomicHTTPD caching proxy
|
//part of the AnomicHTTPD caching proxy
|
||||||
//(C) by Michael Peter Christen; mc@yacy.net
|
//(C) by Michael Peter Christen; mc@yacy.net
|
||||||
//first published on http://www.anomic.de
|
//first published on http://www.anomic.de
|
||||||
//Frankfurt, Germany, 2004
|
//Frankfurt, Germany, 2004
|
||||||
//
|
//
|
||||||
//This File is contributed by Alexander Schier
|
//This File is contributed by Alexander Schier
|
||||||
//last major change: 14.12.2004
|
//last major change: 14.12.2004
|
||||||
//
|
//
|
||||||
//This program is free software; you can redistribute it and/or modify
|
//This program is free software; you can redistribute it and/or modify
|
||||||
//it under the terms of the GNU General Public License as published by
|
//it under the terms of the GNU General Public License as published by
|
||||||
//the Free Software Foundation; either version 2 of the License, or
|
//the Free Software Foundation; either version 2 of the License, or
|
||||||
//(at your option) any later version.
|
//(at your option) any later version.
|
||||||
//
|
//
|
||||||
//This program is distributed in the hope that it will be useful,
|
//This program is distributed in the hope that it will be useful,
|
||||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
//GNU General Public License for more details.
|
//GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
//You should have received a copy of the GNU General Public License
|
//You should have received a copy of the GNU General Public License
|
||||||
//along with this program; if not, write to the Free Software
|
//along with this program; if not, write to the Free Software
|
||||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
//You must compile this file with
|
//You must compile this file with
|
||||||
//javac -classpath .:../classes ViewLog_p.java
|
//javac -classpath .:../classes ViewLog_p.java
|
||||||
//if the shell's current path is HTROOT
|
//if the shell's current path is HTROOT
|
||||||
|
|
||||||
import java.util.logging.Handler;
|
import java.util.logging.Handler;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
import net.yacy.cora.protocol.RequestHeader;
|
import net.yacy.cora.protocol.RequestHeader;
|
||||||
import net.yacy.kelondro.logging.GuiHandler;
|
import net.yacy.kelondro.logging.GuiHandler;
|
||||||
import net.yacy.kelondro.logging.Log;
|
import net.yacy.kelondro.logging.Log;
|
||||||
|
import net.yacy.kelondro.logging.LogalizerHandler;
|
||||||
import de.anomic.server.serverObjects;
|
|
||||||
import de.anomic.server.serverSwitch;
|
import de.anomic.server.serverObjects;
|
||||||
|
import de.anomic.server.serverSwitch;
|
||||||
public class ViewLog_p {
|
|
||||||
|
public class ViewLog_p {
|
||||||
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
|
||||||
final serverObjects prop = new serverObjects();
|
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
||||||
String[] log = new String[0];
|
final serverObjects prop = new serverObjects();
|
||||||
boolean reversed = false;
|
String[] log = new String[0];
|
||||||
boolean json = false;
|
boolean reversed = false;
|
||||||
int maxlines = 400, lines = 200;
|
boolean json = false;
|
||||||
/* Usually a regex like this would make no sense, ".*" would be
|
int maxlines = 400, lines = 200;
|
||||||
* sufficient, but ".*.*" makes it a little bit more convenient
|
String filter = ".*.*";
|
||||||
* for the user to input regexes like ".*FOO.*" in the HTML
|
|
||||||
* interface.
|
if(post != null){
|
||||||
*/
|
if(post.containsKey("mode") && (post.get("mode")).equals("reversed")){
|
||||||
String filter = ".*.*";
|
reversed=true;
|
||||||
|
}
|
||||||
if(post != null){
|
if(post.containsKey("lines")){
|
||||||
reversed = (post.containsKey("mode") && (post.get("mode")).equals("reversed"));
|
lines = Integer.parseInt(post.get("lines"));
|
||||||
json = post.containsKey("json");
|
}
|
||||||
|
if(post.containsKey("filter")){
|
||||||
if(post.containsKey("lines")){
|
filter = post.get("filter");
|
||||||
lines = Integer.parseInt(post.get("lines"));
|
}
|
||||||
}
|
if(post.containsKey("json")){
|
||||||
|
json = true;
|
||||||
if(post.containsKey("filter")){
|
}
|
||||||
filter = post.get("filter");
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
final Logger logger = Logger.getLogger("");
|
||||||
|
final Handler[] handlers = logger.getHandlers();
|
||||||
final Logger logger = Logger.getLogger("");
|
boolean displaySubmenu = false;
|
||||||
final Handler[] handlers = logger.getHandlers();
|
for (int i=0; i<handlers.length; i++) {
|
||||||
for (final Handler handler : handlers) {
|
if (handlers[i] instanceof GuiHandler) {
|
||||||
if (handler instanceof GuiHandler) {
|
maxlines = ((GuiHandler)handlers[i]).getSize();
|
||||||
maxlines = ((GuiHandler)handler).getSize();
|
if (lines > maxlines) lines = maxlines;
|
||||||
if (lines > maxlines) lines = maxlines;
|
log = ((GuiHandler)handlers[i]).getLogLines(reversed,lines);
|
||||||
log = ((GuiHandler)handler).getLogLines(reversed,lines);
|
} else if (handlers[i] instanceof LogalizerHandler) {
|
||||||
}
|
displaySubmenu = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
prop.put("reverseChecked", reversed ? "1" : "0");
|
|
||||||
prop.put("lines", lines);
|
prop.put("submenu", displaySubmenu ? "1" : "0");
|
||||||
prop.put("maxlines",maxlines);
|
prop.put("reverseChecked", reversed ? "1" : "0");
|
||||||
prop.putHTML("filter", filter);
|
prop.put("lines", lines);
|
||||||
|
prop.put("maxlines",maxlines);
|
||||||
// trying to compile the regular expression filter expression
|
prop.putHTML("filter", filter);
|
||||||
Matcher filterMatcher = null;
|
|
||||||
try {
|
// trying to compile the regular expression filter expression
|
||||||
final Pattern filterPattern = Pattern.compile(filter,Pattern.MULTILINE);
|
Matcher filterMatcher = null;
|
||||||
filterMatcher = filterPattern.matcher("");
|
try {
|
||||||
} catch (final PatternSyntaxException e) {
|
final Pattern filterPattern = Pattern.compile(filter,Pattern.MULTILINE);
|
||||||
Log.logException(e);
|
filterMatcher = filterPattern.matcher("");
|
||||||
}
|
} catch (final PatternSyntaxException e) {
|
||||||
|
Log.logException(e);
|
||||||
|
}
|
||||||
int level = 0;
|
|
||||||
int lc = 0;
|
|
||||||
for (final String logLine : log) {
|
int level = 0;
|
||||||
final String nextLogLine = logLine.trim();
|
int lc = 0;
|
||||||
|
for (int i=0; i < log.length; i++) {
|
||||||
if (filterMatcher != null) {
|
final String nextLogLine = log[i].trim();
|
||||||
filterMatcher.reset(nextLogLine);
|
|
||||||
if (!filterMatcher.find()) continue;
|
if (filterMatcher != null) {
|
||||||
}
|
filterMatcher.reset(nextLogLine);
|
||||||
|
if (!filterMatcher.find()) continue;
|
||||||
if (nextLogLine.startsWith("E ")) {
|
}
|
||||||
level = 4;
|
|
||||||
} else if (nextLogLine.startsWith("W ")) {
|
if (nextLogLine.startsWith("E ")) level = 4;
|
||||||
level = 3;
|
else if (nextLogLine.startsWith("W ")) level = 3;
|
||||||
} else if (nextLogLine.startsWith("S ")) {
|
else if (nextLogLine.startsWith("S ")) level = 2;
|
||||||
level = 2;
|
else if (nextLogLine.startsWith("I ")) level = 1;
|
||||||
} else if (nextLogLine.startsWith("I ")) {
|
else if (nextLogLine.startsWith("D ")) level = 0;
|
||||||
level = 1;
|
prop.put("log_" + lc + "_level", level);
|
||||||
} else if (nextLogLine.startsWith("D ")) {
|
if (json) prop.putJSON("log_" + lc + "_line", nextLogLine);
|
||||||
level = 0;
|
else prop.put("log_" + lc + "_line", nextLogLine);
|
||||||
}
|
lc++;
|
||||||
|
}
|
||||||
prop.put("log_" + lc + "_level", level);
|
prop.put("log", lc);
|
||||||
|
|
||||||
if (json) {
|
// return rewrite properties
|
||||||
prop.putJSON("log_" + lc + "_line", nextLogLine);
|
return prop;
|
||||||
} else {
|
}
|
||||||
prop.put("log_" + lc + "_line", nextLogLine);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
lc++;
|
|
||||||
}
|
|
||||||
prop.put("log", lc);
|
|
||||||
|
|
||||||
// return rewrite properties
|
|
||||||
return prop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in new issue