diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/LogsHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/LogsHelper.java index 18e4301f17d6e7d05711807e729530c1aea990dc..1b5a878a681cc64ba1773c24cc0acf362335f372 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/LogsHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/LogsHelper.java @@ -114,28 +114,28 @@ public class LogsHelper extends HelperBase { return "Undefined"; } - /***** unused - public String getConnectionLogs() { - return formatMessages(_context.commSystem().getMostRecentErrorMessages()); - } - ******/ - private final static String NL = System.getProperty("line.separator"); - /** formats in reverse order */ + /** formats in forward order */ private String formatMessages(List<String> msgs) { if (msgs.isEmpty()) return "</td></tr><tr><td><p><i>" + _t("No log messages") + "</i></p>"; boolean colorize = _context.getBooleanPropertyDefaultTrue("routerconsole.logs.color"); StringBuilder buf = new StringBuilder(16*1024); buf.append("</td></tr><tr><td><ul>"); - for (int i = msgs.size() - 1; i >= 0; i--) { + // newest first + // for (int i = msgs.size() - 1; i >= 0; i--) { + // oldest first + for (int i = 0; i < msgs.size(); i++) { String msg = msgs.get(i); // don't display the dup message if it is last - if (i == 0 && msg.contains("↓")) + //if (i == 0 && msg.contains("↓")) + // don't display the dup message if it is first + if (i == 0 && msg.contains("↑")) break; msg = msg.replace("&", "&").replace("<", "<").replace(">", ">"); - msg = msg.replace("&darr;", "↓"); // hack - undo the damage (LogWriter) + //msg = msg.replace("&darr;", "↓"); // hack - undo the damage (LogWriter) + msg = msg.replace("&uarr;", "↑"); // hack - undo the damage (LogWriter) // remove last \n that LogRecordFormatter added if (msg.endsWith(NL)) msg = msg.substring(0, msg.length() - NL.length()); diff --git a/core/java/src/net/i2p/util/LogWriter.java b/core/java/src/net/i2p/util/LogWriter.java index 38830841b6c4b6618277e86b2b320a676d7b5835..f7b91aae9032e9754fee5d69b81d6769fd38874f 100644 --- a/core/java/src/net/i2p/util/LogWriter.java +++ b/core/java/src/net/i2p/util/LogWriter.java @@ -24,6 +24,8 @@ abstract class LogWriter implements Runnable { final static long FLUSH_INTERVAL = 29 * 1000; private final static long MIN_FLUSH_INTERVAL = 2*1000; private final static long MAX_FLUSH_INTERVAL = 5*60*1000; + // true for newest first on /logs page; false for oldest first + private static final boolean BUFFER_DISPLAYED_REVERSE = false; private long _lastReadConfig; protected final LogManager _manager; @@ -137,11 +139,11 @@ abstract class LogWriter implements Runnable { * @since 0.9.21 */ private void writeDupMessage(int dupCount, LogRecord lastRecord) { - String dmsg = dupMessage(dupCount, lastRecord, false); + String dmsg = dupMessage(dupCount, lastRecord, false, false); writeRecord(lastRecord.getPriority(), dmsg); if (_manager.getDisplayOnScreenLevel() <= lastRecord.getPriority() && _manager.displayOnScreen()) System.out.print(dmsg); - dmsg = dupMessage(dupCount, lastRecord, true); + dmsg = dupMessage(dupCount, lastRecord, BUFFER_DISPLAYED_REVERSE, true); _manager.getBuffer().add(dmsg); if (lastRecord.getPriority() >= Log.CRIT) _manager.getBuffer().addCritical(dmsg); @@ -151,8 +153,10 @@ abstract class LogWriter implements Runnable { * Return a msg with the date stamp of the last duplicate * @since 0.9.3 */ - private String dupMessage(int dupCount, LogRecord lastRecord, boolean reverse) { - String arrows = reverse ? (SystemVersion.isAndroid() ? "vvv" : "↓↓↓") : "^^^"; + private String dupMessage(int dupCount, LogRecord lastRecord, boolean reverse, boolean html) { + boolean nohtml = !html || SystemVersion.isAndroid(); + String arrows = reverse ? (nohtml ? "vvv" : "↓↓↓") + : (nohtml ? "^^^" : "↑↑↑"); return LogRecordFormatter.getWhen(_manager, lastRecord) + ' ' + arrows + ' ' + _t(dupCount, "1 similar message omitted", "{0} similar messages omitted") + ' ' + arrows + LogRecordFormatter.NL;