Changeset e969213


Ignore:
Timestamp:
May 28, 2016 11:39:13 PM (4 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
147a7e4, efcf294
Parents:
03e188b5
Message:

Dynamically load Android LogWriter?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/util/LogManager.java

    r03e188b5 re969213  
    1313import java.io.Flushable;
    1414import java.io.IOException;
     15import java.lang.reflect.Constructor;
     16import java.lang.reflect.InvocationTargetException;
    1517import java.text.DateFormat;
    1618import java.text.DecimalFormat;
     
    164166        if (_writer != null)
    165167            return;
    166         _writer = new FileLogWriter(this);
     168        if (SystemVersion.isAndroid()) {
     169            try {
     170                Class<?> clazz = Class.forName("net.i2p.util.AndroidLogWriter");
     171                Constructor<?> ctor = clazz.getDeclaredConstructor(LogManager.class);
     172                _writer = (LogWriter) ctor.newInstance(this);
     173            } catch (ClassNotFoundException e) {
     174            } catch (InstantiationException e) {
     175            } catch (IllegalAccessException e) {
     176            } catch (InvocationTargetException e) {
     177            } catch (NoSuchMethodException e) {
     178            }
     179        }
     180        // Default writer
     181        if (_writer == null)
     182            _writer = new FileLogWriter(this);
    167183        _writer.setFlushInterval(_flushInterval * 1000);
    168184        // if you enable logging in I2PThread again, you MUST change this back to Thread
Note: See TracChangeset for help on using the changeset viewer.