Logs: Windows line ending fixes for event log and duplicate message in router log

This commit is contained in:
zzz
2015-12-11 15:06:22 +00:00
parent 32df925fa6
commit 393b593785
3 changed files with 8 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ import net.i2p.data.DataHelper;
*
*/
class LogRecordFormatter {
private final static String NL = System.getProperty("line.separator");
final static String NL = System.getProperty("line.separator");
// arbitrary max length for the classname property (this makes is it lines up nicely)
private final static int MAX_WHERE_LENGTH = 30;
// if we're going to have one for where... be consistent

View File

@@ -147,7 +147,8 @@ abstract class LogWriterBase implements Runnable {
private String dupMessage(int dupCount, LogRecord lastRecord, boolean reverse) {
String arrows = reverse ? (SystemVersion.isAndroid() ? "vvv" : "↓↓↓") : "^^^";
return LogRecordFormatter.getWhen(_manager, lastRecord) + ' ' + arrows + ' ' +
_t(dupCount, "1 similar message omitted", "{0} similar messages omitted") + ' ' + arrows + '\n';
_t(dupCount, "1 similar message omitted", "{0} similar messages omitted") + ' ' + arrows +
LogRecordFormatter.NL;
}
private static final String BUNDLE_NAME = "net.i2p.router.web.messages";

View File

@@ -15,6 +15,7 @@ import java.util.TreeMap;
import net.i2p.I2PAppContext;
import net.i2p.data.DataHelper;
import net.i2p.util.SecureFileOutputStream;
import net.i2p.util.SystemVersion;
/**
* Simple event logger for occasional events,
@@ -94,6 +95,8 @@ public class EventLog {
buf.append(_context.clock().now()).append(' ').append(event);
if (info != null && info.length() > 0)
buf.append(' ').append(info);
if (SystemVersion.isWindows())
buf.append('\r');
buf.append('\n');
out.write(buf.toString().getBytes("UTF-8"));
} catch (IOException ioe) {
@@ -126,7 +129,7 @@ public class EventLog {
String line = null;
while ( (line = br.readLine()) != null) {
try {
String[] s = DataHelper.split(line, " ", 3);
String[] s = DataHelper.split(line.trim(), " ", 3);
if (!s[1].equals(event))
continue;
long time = Long.parseLong(s[0]);
@@ -168,7 +171,7 @@ public class EventLog {
String line = null;
while ( (line = br.readLine()) != null) {
try {
String[] s = DataHelper.split(line, " ", 2);
String[] s = DataHelper.split(line.trim(), " ", 2);
if (s.length < 2)
continue;
long time = Long.parseLong(s[0]);