*) Displaying servere and warning logging messages in different colors on ViewLog_p.html

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2678 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent f8ac694e51
commit 8b2ceddb91

@ -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>

@ -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 properties
return prop;
}

@ -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%;
}

@ -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

Loading…
Cancel
Save