Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) Displaying servere and warning logging messages in different colors on ViewLog_p.html
theli8b2ceddb91d4
diff --git a/htroot/ViewLog_p.html b/htroot/ViewLog_p.htmlindex 123a3e70e..93d9138d5 100644--- a/htroot/ViewLog_p.html+++ b/htroot/ViewLog_p.html@@ -16,8 +16,9 @@</fieldset></form>- <pre>#[log]#</pre>-+ <div class="log">+ #{log}#<pre class="log#(level)#Debug::Info::System::Warning::Severe#(/level)#">#[line]#</pre>#{/log}#+ </div>#%env/templates/footer.template%#</body>diff --git a/htroot/ViewLog_p.java b/htroot/ViewLog_p.javaindex e492c3497..1f59be1f4 100644--- a/htroot/ViewLog_p.java+++ b/htroot/ViewLog_p.java@@ -56,10 +56,9 @@ import de.anomic.server.logging.GuiHandler;public class ViewLog_p {-public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {serverObjects prop = new serverObjects();- String log = "";+ String[] log = new String[0];boolean reversed = false;int lines = 50;@@ -77,15 +76,29 @@ public class ViewLog_p {Handler[] handlers = logger.getHandlers();for (int i=0; i<handlers.length; i++) {if (handlers[i] instanceof GuiHandler) {- log = ((GuiHandler)handlers[i]).getLog(reversed,lines);+ log = ((GuiHandler)handlers[i]).getLogLines(reversed,lines);break;}}prop.put("reverseChecked", reversed ? 1 : 0);- prop.put("log", log);prop.put("lines", lines);++ int level = 0;+ for (int i=0; i < log.length; i++) {+ String nextLogLine = log[i];+ if (nextLogLine.startsWith("E ")) level = 4;+ else if (nextLogLine.startsWith("W ")) level = 3;+ else if (nextLogLine.startsWith("S ")) level = 2;+ else if (nextLogLine.startsWith("I ")) level = 1;+ else if (nextLogLine.startsWith("D ")) level = 0;++ prop.put("log_" + i + "_level",level);+ prop.put("log_" + i + "_line", nextLogLine);+ }+ prop.put("log",log.length);+// return rewrite propertiesreturn prop;}diff --git a/htroot/env/base.css b/htroot/env/base.cssindex 7a1e0aadb..277def36d 100644--- a/htroot/env/base.css+++ b/htroot/env/base.css@@ -339,12 +339,41 @@ dl.pairs dd {}/* for pages: */++body#ViewLog div.log {+ height:480px;+ overflow:scroll;+}body#ViewLog pre {- width:100%; /* TODO: fix width in IE */- height:480px;- overflow:scroll;-}+ width:100%; /* TODO: fix width in IE */+ margin-top:0px;+ margin-bottom:0px;+ font-family: Courier,monospace;+ font-weight: normal;+ font-size: small;+}++body#ViewLog pre.logSevere {+ color:red;+}++body#ViewLog pre.logWarning {+ color:orange+}++body#ViewLog pre.logSystem {+ color:black;+}++body#ViewLog pre.logInfo {+ color:black;+}++body#ViewLog pre.logDebug {+ color:black;+}+body#QuickCrawlLink p, body#QuickCrawlLink h4 {padding:0 5%;}diff --git a/source/de/anomic/server/logging/GuiHandler.java b/source/de/anomic/server/logging/GuiHandler.javaindex d8e27139f..c509ffcc4 100644--- a/source/de/anomic/server/logging/GuiHandler.java+++ b/source/de/anomic/server/logging/GuiHandler.java@@ -44,6 +44,7 @@package de.anomic.server.logging;+import java.util.ArrayList;import java.util.logging.ErrorManager;import java.util.logging.Filter;import java.util.logging.Formatter;@@ -187,6 +188,32 @@ public class GuiHandler extends Handler{}}+ public synchronized String[] getLogLines(boolean reversed, int lineCount) {++ if ((lineCount > this.count)||(lineCount < 0)) lineCount = this.count;++ ArrayList logMessages = new ArrayList(this.count);+ Formatter logFormatter = getFormatter();++ try {+ int start = (reversed)?this.start+this.count-1:this.start;+ LogRecord record=null;+ for (int i = 0; i < lineCount; i++) {+ int ix = (reversed) ?+ Math.abs((start-i)%this.buffer.length) :+ (start+i)%this.buffer.length;+ record = this.buffer[ix];+ logMessages.add(logFormatter.format(record));+ }+ return (String[])logMessages.toArray(new String[logMessages.size()]);+ } catch (Exception ex) {+ // We don't want to throw an exception here, but we+ // report the exception to any registered ErrorManager.+ reportError(null, ex, ErrorManager.FORMAT_FAILURE);+ return new String[]{"Error while formatting the logging message"};+ }+ }+public void flush() {// TODO Auto-generated method stub