Combo: remove fabric logging.

This commit is contained in:
Johannes Mockenhaupt 2018-08-27 19:07:46 +02:00
parent e5d96e5c17
commit 0eb08c2eaf
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 1 additions and 107 deletions

View file

@ -7,8 +7,6 @@ import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import com.crashlytics.android.answers.CustomEvent;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -66,7 +64,6 @@ import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
/** /**
@ -556,10 +553,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
} }
if (waitLoops > 0) { if (waitLoops > 0) {
long waitDuration = (System.currentTimeMillis() - waitStartTime) / 1000; long waitDuration = (System.currentTimeMillis() - waitStartTime) / 1000;
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusTimestampWait")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("waitTimeSecs", String.valueOf(waitDuration)));
if (L.isEnabled(L.PUMP)) if (L.isEnabled(L.PUMP))
log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing"); log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing");
} }
@ -681,11 +674,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
} }
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("bolus", String.valueOf(lastPumpBolus.amount))
.putCustomAttribute("issue", "record with same timestamp existed and was overridden"));
return false; return false;
} }
} catch (Exception e) { } catch (Exception e) {
@ -693,11 +681,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
if (dbi.isSMB) { if (dbi.isSMB) {
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("bolus", String.valueOf(lastPumpBolus.amount))
.putCustomAttribute("issue", "adding record caused exception"));
} }
return false; return false;
} }
@ -1111,10 +1094,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) { if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
if (L.isEnabled(L.PUMP)) if (L.isEnabled(L.PUMP))
log.debug("Creating temp basal from pump TBR"); log.debug("Creating temp basal from pump TBR");
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("type", "new TBR on pump"));
TemporaryBasal newTempBasal = new TemporaryBasal() TemporaryBasal newTempBasal = new TemporaryBasal()
.date(now) .date(now)
.percent(state.tbrPercent) .percent(state.tbrPercent)
@ -1124,10 +1103,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
} else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) { } else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) {
if (L.isEnabled(L.PUMP)) if (L.isEnabled(L.PUMP))
log.debug("Ending AAPS-TBR since pump has no TBR active"); log.debug("Ending AAPS-TBR since pump has no TBR active");
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("type", "TBR cancelled on pump"));
TemporaryBasal tempStop = new TemporaryBasal() TemporaryBasal tempStop = new TemporaryBasal()
.date(now) .date(now)
.duration(0) .duration(0)
@ -1138,10 +1113,6 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) { Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) {
if (L.isEnabled(L.PUMP)) if (L.isEnabled(L.PUMP))
log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR"); log.debug("AAPSs and pump-TBR differ; ending AAPS-TBR and creating new TBR based on pump TBR");
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("type", "TBR on pump differs from AAPS TBR"));
TemporaryBasal tempStop = new TemporaryBasal() TemporaryBasal tempStop = new TemporaryBasal()
.date(now - 1000) .date(now - 1000)
.duration(0) .duration(0)
@ -1262,19 +1233,13 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
if (bolusSet.size() != historyResult.history.bolusHistory.size()) { if (bolusSet.size() != historyResult.history.bolusHistory.size()) {
if (L.isEnabled(L.PUMP)) if (L.isEnabled(L.PUMP))
log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB."); log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB.");
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("bolus", "")
.putCustomAttribute("issue", "multiple pump history records with the same time and amount"));
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string. Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.
combo_error_multiple_boluses_with_identical_timestamp), Notification.URGENT); combo_error_multiple_boluses_with_identical_timestamp), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
} }
pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history); pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history);
if (pumpHistoryChanged) { if (L.isEnabled(L.PUMP) && pumpHistoryChanged) {
if (L.isEnabled(L.PUMP))
log.debug("Setting 'pumpHistoryChanged' true"); log.debug("Setting 'pumpHistoryChanged' true");
} }

View file

@ -10,7 +10,6 @@ import android.os.SystemClock;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.crashlytics.android.answers.CustomEvent;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import org.monkey.d.ruffy.ruffy.driver.IRTHandler; import org.monkey.d.ruffy.ruffy.driver.IRTHandler;
@ -39,8 +38,6 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadH
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadPumpStateCommand; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.ReadPumpStateCommand;
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetBasalProfileCommand; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetBasalProfileCommand;
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetTbrCommand; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.commands.SetTbrCommand;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.utils.FabricPrivacy;
/** /**
* Provides scripting 'runtime' and operations. consider moving operations into a separate * Provides scripting 'runtime' and operations. consider moving operations into a separate
@ -76,14 +73,6 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public void fail(String message) throws RemoteException { public void fail(String message) throws RemoteException {
log.warn("Ruffy warns: " + message); log.warn("Ruffy warns: " + message);
if (message.startsWith("no connection possible"))
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "no connection possible"));
else if (message.startsWith("Error sending keep alive while rtModeRunning is still true"))
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "Error sending keep alive while rtModeRunning is still true"));
else if (message.startsWith("Error sending keep alive. rtModeRunning is false, so this is most likely a race condition during disconnect"))
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", "Error sending keep alive. rtModeRunning is false, so this is most likely a race condition during disconnect"));
else
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRuffyWarning").putCustomAttribute("message", message.substring(0, 98)));
} }
@Override @Override
@ -173,10 +162,6 @@ public class RuffyScripter implements RuffyCommands {
if (!boundSucceeded) { if (!boundSucceeded) {
log.error("No connection to ruffy. Pump control unavailable."); log.error("No connection to ruffy. Pump control unavailable.");
} else {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboScripterInit")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
} }
} }
@ -227,9 +212,6 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult readQuickInfo(int numberOfBolusRecordsToRetrieve) { public CommandResult readQuickInfo(int numberOfBolusRecordsToRetrieve) {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadQuickInfoCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ReadQuickInfoCommand(numberOfBolusRecordsToRetrieve)); return runCommand(new ReadQuickInfoCommand(numberOfBolusRecordsToRetrieve));
} }
@ -435,11 +417,6 @@ public class RuffyScripter implements RuffyCommands {
} }
} }
log.debug("Recovery from connection loss " + (connected ? "succeeded" : "failed")); log.debug("Recovery from connection loss " + (connected ? "succeeded" : "failed"));
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromConnectionLoss")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
.putCustomAttribute("success", connected ? "true" : "else"));
return connected; return connected;
} }
@ -450,12 +427,6 @@ public class RuffyScripter implements RuffyCommands {
private PumpState recoverFromCommandFailure() { private PumpState recoverFromCommandFailure() {
Menu menu = this.currentMenu; Menu menu = this.currentMenu;
if (menu == null) { if (menu == null) {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
.putCustomAttribute("exit", "1")
.putCustomAttribute("success", "false"));
return new PumpState(); return new PumpState();
} }
MenuType type = menu.getType(); MenuType type = menu.getType();
@ -469,21 +440,8 @@ public class RuffyScripter implements RuffyCommands {
} }
try { try {
PumpState pumpState = readPumpStateInternal(); PumpState pumpState = readPumpStateInternal();
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
.putCustomAttribute("exit", "2")
.putCustomAttribute("success", "true"));
return pumpState; return pumpState;
} catch (Exception e) { } catch (Exception e) {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboRecoveryFromCommandFailure")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("exit", "3")
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
.putCustomAttribute("success", "false"));
log.debug("Reading pump state during recovery failed", e); log.debug("Reading pump state during recovery failed", e);
return new PumpState(); return new PumpState();
} }
@ -505,11 +463,6 @@ public class RuffyScripter implements RuffyCommands {
long initialUpdateTime = menuLastUpdated; long initialUpdateTime = menuLastUpdated;
while (initialUpdateTime == menuLastUpdated) { while (initialUpdateTime == menuLastUpdated) {
if (System.currentTimeMillis() > timeoutExpired) { if (System.currentTimeMillis() > timeoutExpired) {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboConnectTimeout")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("activeCommand", "" + (activeCmd != null ? activeCmd.getClass().getSimpleName() : ""))
.putCustomAttribute("previousCommand", previousCommand));
throw new CommandException("Timeout connecting to pump"); throw new CommandException("Timeout connecting to pump");
} }
SystemClock.sleep(50); SystemClock.sleep(50);
@ -818,18 +771,12 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult deliverBolus(double amount, BolusProgressReporter bolusProgressReporter) { public CommandResult deliverBolus(double amount, BolusProgressReporter bolusProgressReporter) {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new BolusCommand(amount, bolusProgressReporter)); return runCommand(new BolusCommand(amount, bolusProgressReporter));
} }
@Override @Override
public void cancelBolus() { public void cancelBolus() {
if (activeCmd instanceof BolusCommand) { if (activeCmd instanceof BolusCommand) {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboBolusCmdCancel")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
((BolusCommand) activeCmd).requestCancellation(); ((BolusCommand) activeCmd).requestCancellation();
} else { } else {
log.error("cancelBolus called, but active command is not a bolus:" + activeCmd); log.error("cancelBolus called, but active command is not a bolus:" + activeCmd);
@ -838,49 +785,31 @@ public class RuffyScripter implements RuffyCommands {
@Override @Override
public CommandResult setTbr(int percent, int duration) { public CommandResult setTbr(int percent, int duration) {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboSetTbrCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new SetTbrCommand(percent, duration)); return runCommand(new SetTbrCommand(percent, duration));
} }
@Override @Override
public CommandResult cancelTbr() { public CommandResult cancelTbr() {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboCancelTbrCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new CancelTbrCommand()); return runCommand(new CancelTbrCommand());
} }
@Override @Override
public CommandResult confirmAlert(int warningCode) { public CommandResult confirmAlert(int warningCode) {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboConfirmAlertCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ConfirmAlertCommand(warningCode)); return runCommand(new ConfirmAlertCommand(warningCode));
} }
@Override @Override
public CommandResult readHistory(PumpHistoryRequest request) { public CommandResult readHistory(PumpHistoryRequest request) {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadHistoryCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ReadHistoryCommand(request)); return runCommand(new ReadHistoryCommand(request));
} }
@Override @Override
public CommandResult readBasalProfile() { public CommandResult readBasalProfile() {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboReadBasalProfileCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new ReadBasalProfileCommand()); return runCommand(new ReadBasalProfileCommand());
} }
@Override @Override
public CommandResult setBasalProfile(BasalProfile basalProfile) { public CommandResult setBasalProfile(BasalProfile basalProfile) {
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboSetBasalProfileCmd")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION));
return runCommand(new SetBasalProfileCommand(basalProfile)); return runCommand(new SetBasalProfileCommand(basalProfile));
} }