I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit e9692134 authored by str4d's avatar str4d
Browse files

Dynamically load Android LogWriter

parent 03e188b5
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,8 @@ package net.i2p.util; ...@@ -12,6 +12,8 @@ package net.i2p.util;
import java.io.File; import java.io.File;
import java.io.Flushable; import java.io.Flushable;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -163,7 +165,21 @@ public class LogManager implements Flushable { ...@@ -163,7 +165,21 @@ public class LogManager implements Flushable {
// yeah, this doesn't always work, _writer should be volatile // yeah, this doesn't always work, _writer should be volatile
if (_writer != null) if (_writer != null)
return; return;
_writer = new FileLogWriter(this); if (SystemVersion.isAndroid()) {
try {
Class<?> clazz = Class.forName("net.i2p.util.AndroidLogWriter");
Constructor<?> ctor = clazz.getDeclaredConstructor(LogManager.class);
_writer = (LogWriter) ctor.newInstance(this);
} catch (ClassNotFoundException e) {
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
} catch (NoSuchMethodException e) {
}
}
// Default writer
if (_writer == null)
_writer = new FileLogWriter(this);
_writer.setFlushInterval(_flushInterval * 1000); _writer.setFlushInterval(_flushInterval * 1000);
// if you enable logging in I2PThread again, you MUST change this back to Thread // if you enable logging in I2PThread again, you MUST change this back to Thread
Thread t = new I2PThread(_writer, "LogWriter"); Thread t = new I2PThread(_writer, "LogWriter");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment