Log posted events.

This commit is contained in:
Johannes Mockenhaupt 2017-10-14 15:24:41 +02:00
parent f673d3a721
commit 5a446c9ab5
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 26 additions and 1 deletions

View file

@ -40,6 +40,7 @@ public class Config {
public static final boolean logPumpActions = true;
public static final boolean logCongigBuilderActions = true;
public static final boolean logAutosensData = false;
public static final boolean logEvents = true;
// DanaR specific
public static final boolean logDanaBTComm = true;

View file

@ -0,0 +1,22 @@
package info.nightscout.androidaps;
import com.squareup.otto.Bus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class LoggingBus extends Bus {
private static Logger log = LoggerFactory.getLogger(LoggingBus.class);
private final Bus delegate;
public LoggingBus(Bus bus) {
delegate = bus;
}
@Override
public void post(Object event) {
log.debug("Event posted: " + event);
super.post(event);
}
}

View file

@ -104,7 +104,9 @@ public class MainApp extends Application {
log.info("Version: " + BuildConfig.VERSION_NAME);
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);
sBus = new Bus(ThreadEnforcer.ANY);
Bus bus = new Bus(ThreadEnforcer.ANY);
sBus = Config.logEvents ? new LoggingBus(bus) : bus;
sInstance = this;
sResources = getResources();