diff --git a/htroot/ViewLog_p.html b/htroot/ViewLog_p.html index 123a3e70e..93d9138d5 100644 --- a/htroot/ViewLog_p.html +++ b/htroot/ViewLog_p.html @@ -16,8 +16,9 @@ -
#[log]#
- +
+ #{log}#
#[line]#
#{/log}# +
#%env/templates/footer.template%# diff --git a/htroot/ViewLog_p.java b/htroot/ViewLog_p.java index 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 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