logging cleanup

This commit is contained in:
Milos Kozak 2018-07-30 15:46:20 +02:00
parent 6a9bf04a98
commit 35b51af09c
19 changed files with 112 additions and 103 deletions

View file

@ -23,7 +23,4 @@ public class Config {
public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER; public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
public static boolean logConfigBuilder = true;
public static boolean logCongigBuilderActions = true;
} }

View file

@ -10,11 +10,12 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.Round; import info.nightscout.utils.Round;
public class PumpEnactResult { public class PumpEnactResult {
private static Logger log = LoggerFactory.getLogger(PumpEnactResult.class); private static Logger log = LoggerFactory.getLogger(L.APS);
public boolean success = false; // request was processed successfully (but possible no change was needed) public boolean success = false; // request was processed successfully (but possible no change was needed)
public boolean enacted = false; // request was processed successfully and change has been made public boolean enacted = false; // request was processed successfully and change has been made

View file

@ -15,6 +15,7 @@ import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
@ -25,7 +26,7 @@ import info.nightscout.utils.SP;
@DatabaseTable(tableName = DatabaseHelper.DATABASE_BGREADINGS) @DatabaseTable(tableName = DatabaseHelper.DATABASE_BGREADINGS)
public class BgReading implements DataPointWithLabelInterface { public class BgReading implements DataPointWithLabelInterface {
private static Logger log = LoggerFactory.getLogger(BgReading.class); private static Logger log = LoggerFactory.getLogger(L.DATABASE);
@DatabaseField(id = true) @DatabaseField(id = true)
public long date; public long date;

View file

@ -25,6 +25,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.interfaces.Interval; import info.nightscout.androidaps.interfaces.Interval;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSMbg; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSMbg;
import info.nightscout.androidaps.plugins.Overview.OverviewFragment; import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
@ -36,7 +37,7 @@ import info.nightscout.utils.Translator;
@DatabaseTable(tableName = DatabaseHelper.DATABASE_CAREPORTALEVENTS) @DatabaseTable(tableName = DatabaseHelper.DATABASE_CAREPORTALEVENTS)
public class CareportalEvent implements DataPointWithLabelInterface, Interval { public class CareportalEvent implements DataPointWithLabelInterface, Interval {
private static Logger log = LoggerFactory.getLogger(CareportalEvent.class); private static Logger log = LoggerFactory.getLogger(L.DATABASE);
@DatabaseField(id = true) @DatabaseField(id = true)
public long date; public long date;

View file

@ -10,6 +10,8 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.L;
/** /**
* Created by mike on 27.02.2016. * Created by mike on 27.02.2016.
* <p> * <p>
@ -17,7 +19,7 @@ import org.slf4j.LoggerFactory;
*/ */
@DatabaseTable(tableName = DatabaseHelper.DATABASE_DBREQUESTS) @DatabaseTable(tableName = DatabaseHelper.DATABASE_DBREQUESTS)
public class DbRequest { public class DbRequest {
private static Logger log = LoggerFactory.getLogger(DbRequest.class); private static Logger log = LoggerFactory.getLogger(L.DATABASE);
@DatabaseField(id = true) @DatabaseField(id = true)
public String nsClientID = null; public String nsClientID = null;

View file

@ -21,6 +21,7 @@ import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.interfaces.InsulinInterface; import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.Interval; import info.nightscout.androidaps.interfaces.Interval;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries; import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
@ -36,7 +37,7 @@ import info.nightscout.utils.Round;
@DatabaseTable(tableName = DatabaseHelper.DATABASE_EXTENDEDBOLUSES) @DatabaseTable(tableName = DatabaseHelper.DATABASE_EXTENDEDBOLUSES)
public class ExtendedBolus implements Interval, DataPointWithLabelInterface { public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
private static Logger log = LoggerFactory.getLogger(ExtendedBolus.class); private static Logger log = LoggerFactory.getLogger(L.DATABASE);
@DatabaseField(id = true) @DatabaseField(id = true)
public long date; public long date;

View file

@ -17,6 +17,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.interfaces.Interval; import info.nightscout.androidaps.interfaces.Interval;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries; import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
@ -27,7 +28,7 @@ import info.nightscout.utils.DecimalFormatter;
@DatabaseTable(tableName = DatabaseHelper.DATABASE_PROFILESWITCHES) @DatabaseTable(tableName = DatabaseHelper.DATABASE_PROFILESWITCHES)
public class ProfileSwitch implements Interval, DataPointWithLabelInterface { public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
private static Logger log = LoggerFactory.getLogger(ProfileSwitch.class); private static Logger log = LoggerFactory.getLogger(L.DATABASE);
@DatabaseField(id = true) @DatabaseField(id = true)
public long date; public long date;

View file

@ -8,6 +8,8 @@ import org.slf4j.LoggerFactory;
import java.util.Objects; import java.util.Objects;
import info.nightscout.androidaps.logging.L;
/** /**
* Created by mike on 20.09.2017. * Created by mike on 20.09.2017.
*/ */
@ -15,7 +17,7 @@ import java.util.Objects;
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TDDS) @DatabaseTable(tableName = DatabaseHelper.DATABASE_TDDS)
public class TDD { public class TDD {
private static Logger log = LoggerFactory.getLogger(TDD.class); private static Logger log = LoggerFactory.getLogger(L.DATABASE);
@DatabaseField(id = true) @DatabaseField(id = true)
public long date; public long date;

View file

@ -11,12 +11,13 @@ import java.util.Objects;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.interfaces.Interval; import info.nightscout.androidaps.interfaces.Interval;
import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPTARGETS) @DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPTARGETS)
public class TempTarget implements Interval { public class TempTarget implements Interval {
private static Logger log = LoggerFactory.getLogger(TempTarget.class); private static Logger log = LoggerFactory.getLogger(L.DATABASE);
@DatabaseField(id = true) @DatabaseField(id = true)
public long date; public long date;

View file

@ -15,6 +15,7 @@ import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.interfaces.InsulinInterface; import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.Interval; import info.nightscout.androidaps.interfaces.Interval;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Treatments.Treatment;
@ -28,7 +29,7 @@ import info.nightscout.utils.SP;
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPORARYBASALS) @DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPORARYBASALS)
public class TemporaryBasal implements Interval { public class TemporaryBasal implements Interval {
private static Logger log = LoggerFactory.getLogger(TemporaryBasal.class); private static Logger log = LoggerFactory.getLogger(L.DATABASE);
@DatabaseField(id = true) @DatabaseField(id = true)
public long date; public long date;

View file

@ -6,12 +6,14 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.logging.L;
/** /**
* Created by mike on 19.03.2018. * Created by mike on 19.03.2018.
*/ */
public class Constraint<T extends Comparable> { public class Constraint<T extends Comparable> {
private static Logger log = LoggerFactory.getLogger(Constraint.class); private static Logger log = LoggerFactory.getLogger(L.APS);
T value; T value;
T originalValue; T originalValue;
@ -86,6 +88,7 @@ public class Constraint<T extends Comparable> {
if (count++ != 0) sb.append("\n"); if (count++ != 0) sb.append("\n");
sb.append(r); sb.append(r);
} }
if (L.isEnabled(L.APS))
log.debug("Limiting origial value: " + originalValue + " to " + value + ". Reason: " + sb.toString()); log.debug("Limiting origial value: " + originalValue + " to " + value + ". Reason: " + sb.toString());
return sb.toString(); return sb.toString();
} }
@ -110,7 +113,7 @@ public class Constraint<T extends Comparable> {
} }
public void copyReasons(Constraint<?> another) { public void copyReasons(Constraint<?> another) {
for (String s: another.getReasonList()) { for (String s : another.getReasonList()) {
reasons.add(s); reasons.add(s);
} }
} }

View file

@ -7,6 +7,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
@ -14,7 +15,7 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
* Created by mike on 09.06.2016. * Created by mike on 09.06.2016.
*/ */
public abstract class PluginBase { public abstract class PluginBase {
private static Logger log = LoggerFactory.getLogger(PluginBase.class); private static Logger log = LoggerFactory.getLogger(L.CORE);
public enum State { public enum State {
NOT_INITIALIZED, NOT_INITIALIZED,
@ -113,6 +114,7 @@ public abstract class PluginBase {
if (state != State.ENABLED) { if (state != State.ENABLED) {
onStateChange(type, state, State.ENABLED); onStateChange(type, state, State.ENABLED);
state = State.ENABLED; state = State.ENABLED;
if (L.isEnabled(L.CORE))
log.debug("Starting: " + getName()); log.debug("Starting: " + getName());
onStart(); onStart();
} }
@ -121,6 +123,7 @@ public abstract class PluginBase {
onStateChange(type, state, State.ENABLED); onStateChange(type, state, State.ENABLED);
state = State.DISABLED; state = State.DISABLED;
onStop(); onStop();
if (L.isEnabled(L.CORE))
log.debug("Stopping: " + getName()); log.debug("Stopping: " + getName());
} }
} }

View file

@ -76,10 +76,12 @@ public class L {
public static final String PUMPBTCOMM = "PUMPBTCOMM"; public static final String PUMPBTCOMM = "PUMPBTCOMM";
public static final String APS = "APS"; public static final String APS = "APS";
public static final String PROFILE = "PROFILE"; public static final String PROFILE = "PROFILE";
public static final String CONFIGBUILDER = "CONFIGBUILDER";
private static void initialize() { private static void initialize() {
logElements = new ArrayList<>(); logElements = new ArrayList<>();
logElements.add(new LogElement(CORE, true)); logElements.add(new LogElement(CORE, true));
logElements.add(new LogElement(CONFIGBUILDER, true));
logElements.add(new LogElement(AUTOSENS, false)); logElements.add(new LogElement(AUTOSENS, false));
logElements.add(new LogElement(EVENTS, false, true)); logElements.add(new LogElement(EVENTS, false, true));
logElements.add(new LogElement(BGSOURCE, true)); logElements.add(new LogElement(BGSOURCE, true));

View file

@ -1,35 +1,17 @@
package info.nightscout.androidaps.plugins.ConfigBuilder; package info.nightscout.androidaps.plugins.ConfigBuilder;
import android.content.Intent;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventAppInitialized; import info.nightscout.androidaps.events.EventAppInitialized;
import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.events.EventProfileSwitchChange;
import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.BgSourceInterface; import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.InsulinInterface; import info.nightscout.androidaps.interfaces.InsulinInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
@ -38,24 +20,18 @@ import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.SensitivityInterface; import info.nightscout.androidaps.interfaces.SensitivityInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin; import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityOref0Plugin; import info.nightscout.androidaps.plugins.Sensitivity.SensitivityOref0Plugin;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.CommandQueue; import info.nightscout.androidaps.queue.CommandQueue;
import info.nightscout.utils.FabricPrivacy;
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils;
/** /**
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class ConfigBuilderPlugin extends PluginBase { public class ConfigBuilderPlugin extends PluginBase {
private static Logger log = LoggerFactory.getLogger(ConfigBuilderPlugin.class); private Logger log = LoggerFactory.getLogger(L.CONFIGBUILDER);
private static ConfigBuilderPlugin configBuilderPlugin; private static ConfigBuilderPlugin configBuilderPlugin;
@ -113,14 +89,15 @@ public class ConfigBuilderPlugin extends PluginBase {
private void setAlwaysEnabledPluginsEnabled() { private void setAlwaysEnabledPluginsEnabled() {
for (PluginBase plugin : pluginList) { for (PluginBase plugin : pluginList) {
if (plugin.pluginDescription.alwaysEnabled) plugin.setPluginEnabled(plugin.getType(), true); if (plugin.pluginDescription.alwaysEnabled)
plugin.setPluginEnabled(plugin.getType(), true);
} }
storeSettings("setAlwaysEnabledPluginsEnabled"); storeSettings("setAlwaysEnabledPluginsEnabled");
} }
public void storeSettings(String from) { public void storeSettings(String from) {
if (pluginList != null) { if (pluginList != null) {
if (Config.logConfigBuilder) if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Storing settings from: " + from); log.debug("Storing settings from: " + from);
for (PluginBase p : pluginList) { for (PluginBase p : pluginList) {
@ -143,16 +120,18 @@ public class ConfigBuilderPlugin extends PluginBase {
private void savePref(PluginBase p, PluginType type, boolean storeVisible) { private void savePref(PluginBase p, PluginType type, boolean storeVisible) {
String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled"; String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled";
SP.putBoolean(settingEnabled, p.isEnabled(type)); SP.putBoolean(settingEnabled, p.isEnabled(type));
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Storing: " + settingEnabled + ":" + p.isEnabled(type)); log.debug("Storing: " + settingEnabled + ":" + p.isEnabled(type));
if (storeVisible) { if (storeVisible) {
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible"; String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
SP.putBoolean(settingVisible, p.isFragmentVisible()); SP.putBoolean(settingVisible, p.isFragmentVisible());
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Storing: " + settingVisible + ":" + p.isFragmentVisible()); log.debug("Storing: " + settingVisible + ":" + p.isFragmentVisible());
} }
} }
private void loadSettings() { private void loadSettings() {
if (Config.logConfigBuilder) if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Loading stored settings"); log.debug("Loading stored settings");
for (PluginBase p : pluginList) { for (PluginBase p : pluginList) {
PluginType type = p.getType(); PluginType type = p.getType();
@ -173,6 +152,7 @@ public class ConfigBuilderPlugin extends PluginBase {
else if (p.getType() == type && (p.pluginDescription.enableByDefault || p.pluginDescription.alwaysEnabled)) { else if (p.getType() == type && (p.pluginDescription.enableByDefault || p.pluginDescription.alwaysEnabled)) {
p.setPluginEnabled(type, true); p.setPluginEnabled(type, true);
} }
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Loaded: " + settingEnabled + ":" + p.isEnabled(type)); log.debug("Loaded: " + settingEnabled + ":" + p.isEnabled(type));
if (loadVisible) { if (loadVisible) {
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible"; String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
@ -181,6 +161,7 @@ public class ConfigBuilderPlugin extends PluginBase {
else if (p.getType() == type && p.pluginDescription.visibleByDefault) { else if (p.getType() == type && p.pluginDescription.visibleByDefault) {
p.setFragmentVisible(type, true); p.setFragmentVisible(type, true);
} }
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Loaded: " + settingVisible + ":" + p.isFragmentVisible()); log.debug("Loaded: " + settingVisible + ":" + p.isFragmentVisible());
} }
} }
@ -189,9 +170,10 @@ public class ConfigBuilderPlugin extends PluginBase {
private void upgradeSettings() { private void upgradeSettings() {
if (!SP.contains("ConfigBuilder_1_NSProfilePlugin_Enabled")) if (!SP.contains("ConfigBuilder_1_NSProfilePlugin_Enabled"))
return; return;
if (Config.logConfigBuilder) if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Upgrading stored settings"); log.debug("Upgrading stored settings");
for (PluginBase p : pluginList) { for (PluginBase p : pluginList) {
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Processing " + p.getName()); log.debug("Processing " + p.getName());
for (int type = 1; type < 11; type++) { for (int type = 1; type < 11; type++) {
PluginType newType; PluginType newType;
@ -276,6 +258,7 @@ public class ConfigBuilderPlugin extends PluginBase {
} }
void logPluginStatus() { void logPluginStatus() {
if (L.isEnabled(L.CONFIGBUILDER))
for (PluginBase p : pluginList) { for (PluginBase p : pluginList) {
log.debug(p.getName() + ":" + log.debug(p.getName() + ":" +
(p.isEnabled(PluginType.GENERAL) ? " GENERAL" : "") + (p.isEnabled(PluginType.GENERAL) ? " GENERAL" : "") +
@ -386,7 +369,7 @@ public class ConfigBuilderPlugin extends PluginBase {
private void setFragmentVisiblities(String activePluginName, ArrayList<PluginBase> pluginsInCategory, private void setFragmentVisiblities(String activePluginName, ArrayList<PluginBase> pluginsInCategory,
PluginType pluginType) { PluginType pluginType) {
if (Config.logConfigBuilder) if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Selected interface: " + activePluginName); log.debug("Selected interface: " + activePluginName);
for (PluginBase p : pluginsInCategory) { for (PluginBase p : pluginsInCategory) {
if (!p.getName().equals(activePluginName)) { if (!p.getName().equals(activePluginName)) {

View file

@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainActivity; import info.nightscout.androidaps.MainActivity;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
@ -447,6 +446,7 @@ public class LoopPlugin extends PluginBase {
request.rate = MainApp.getConstraintChecker().applyBasalConstraints(request.rateConstraint, profile).value(); request.rate = MainApp.getConstraintChecker().applyBasalConstraints(request.rateConstraint, profile).value();
if (!pump.isInitialized()) { if (!pump.isInitialized()) {
if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: " + MainApp.gs(R.string.pumpNotInitialized)); log.debug("applyAPSRequest: " + MainApp.gs(R.string.pumpNotInitialized));
if (callback != null) { if (callback != null) {
callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run(); callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run();
@ -455,6 +455,7 @@ public class LoopPlugin extends PluginBase {
} }
if (pump.isSuspended()) { if (pump.isSuspended()) {
if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: " + MainApp.gs(R.string.pumpsuspended)); log.debug("applyAPSRequest: " + MainApp.gs(R.string.pumpsuspended));
if (callback != null) { if (callback != null) {
callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpsuspended)).enacted(false).success(false)).run(); callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpsuspended)).enacted(false).success(false)).run();
@ -462,18 +463,18 @@ public class LoopPlugin extends PluginBase {
return; return;
} }
if (Config.logCongigBuilderActions) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: " + request.toString()); log.debug("applyAPSRequest: " + request.toString());
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
TemporaryBasal activeTemp = activeTreatments.getTempBasalFromHistory(now); TemporaryBasal activeTemp = activeTreatments.getTempBasalFromHistory(now);
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) { if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) {
if (activeTemp != null) { if (activeTemp != null) {
if (Config.logCongigBuilderActions) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: cancelTempBasal()"); log.debug("applyAPSRequest: cancelTempBasal()");
MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(false, callback); MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(false, callback);
} else { } else {
if (Config.logCongigBuilderActions) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: Basal set correctly"); log.debug("applyAPSRequest: Basal set correctly");
if (callback != null) { if (callback != null) {
callback.result(new PumpEnactResult().absolute(request.rate).duration(0) callback.result(new PumpEnactResult().absolute(request.rate).duration(0)
@ -484,7 +485,7 @@ public class LoopPlugin extends PluginBase {
&& activeTemp.getPlannedRemainingMinutes() > 5 && activeTemp.getPlannedRemainingMinutes() > 5
&& request.duration - activeTemp.getPlannedRemainingMinutes() < 30 && request.duration - activeTemp.getPlannedRemainingMinutes() < 30
&& Math.abs(request.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < pump.getPumpDescription().basalStep) { && Math.abs(request.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < pump.getPumpDescription().basalStep) {
if (Config.logCongigBuilderActions) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: Temp basal set correctly"); log.debug("applyAPSRequest: Temp basal set correctly");
if (callback != null) { if (callback != null) {
callback.result(new PumpEnactResult().absolute(activeTemp.tempBasalConvertedToAbsolute(now, profile)) callback.result(new PumpEnactResult().absolute(activeTemp.tempBasalConvertedToAbsolute(now, profile))
@ -492,7 +493,7 @@ public class LoopPlugin extends PluginBase {
.comment(MainApp.gs(R.string.let_temp_basal_run))).run(); .comment(MainApp.gs(R.string.let_temp_basal_run))).run();
} }
} else { } else {
if (Config.logCongigBuilderActions) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: setTempBasalAbsolute()"); log.debug("applyAPSRequest: setTempBasalAbsolute()");
MainApp.getConfigBuilder().getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback); MainApp.getConfigBuilder().getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback);
} }
@ -508,6 +509,7 @@ public class LoopPlugin extends PluginBase {
long lastBolusTime = activeTreatments.getLastBolusTime(); long lastBolusTime = activeTreatments.getLastBolusTime();
if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) { if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) {
if (L.isEnabled(L.APS))
log.debug("SMB requested but still in 3 min interval"); log.debug("SMB requested but still in 3 min interval");
if (callback != null) { if (callback != null) {
callback.result(new PumpEnactResult() callback.result(new PumpEnactResult()
@ -518,6 +520,7 @@ public class LoopPlugin extends PluginBase {
} }
if (!pump.isInitialized()) { if (!pump.isInitialized()) {
if (L.isEnabled(L.APS))
log.debug("applySMBRequest: " + MainApp.gs(R.string.pumpNotInitialized)); log.debug("applySMBRequest: " + MainApp.gs(R.string.pumpNotInitialized));
if (callback != null) { if (callback != null) {
callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run(); callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run();
@ -526,6 +529,7 @@ public class LoopPlugin extends PluginBase {
} }
if (pump.isSuspended()) { if (pump.isSuspended()) {
if (L.isEnabled(L.APS))
log.debug("applySMBRequest: " + MainApp.gs(R.string.pumpsuspended)); log.debug("applySMBRequest: " + MainApp.gs(R.string.pumpsuspended));
if (callback != null) { if (callback != null) {
callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpsuspended)).enacted(false).success(false)).run(); callback.result(new PumpEnactResult().comment(MainApp.gs(R.string.pumpsuspended)).enacted(false).success(false)).run();
@ -533,7 +537,7 @@ public class LoopPlugin extends PluginBase {
return; return;
} }
if (Config.logCongigBuilderActions) if (L.isEnabled(L.APS))
log.debug("applySMBRequest: " + request.toString()); log.debug("applySMBRequest: " + request.toString());
// deliver SMB // deliver SMB
@ -544,7 +548,7 @@ public class LoopPlugin extends PluginBase {
detailedBolusInfo.isSMB = true; detailedBolusInfo.isSMB = true;
detailedBolusInfo.source = Source.USER; detailedBolusInfo.source = Source.USER;
detailedBolusInfo.deliverAt = request.deliverAt; detailedBolusInfo.deliverAt = request.deliverAt;
if (Config.logCongigBuilderActions) if (L.isEnabled(L.APS))
log.debug("applyAPSRequest: bolus()"); log.debug("applyAPSRequest: bolus()");
MainApp.getConfigBuilder().getCommandQueue().bolus(detailedBolusInfo, callback); MainApp.getConfigBuilder().getCommandQueue().bolus(detailedBolusInfo, callback);
} }

View file

@ -7,8 +7,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.PowerManager; import android.os.PowerManager;
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
import info.nightscout.utils.FabricPrivacy;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -16,11 +14,14 @@ import java.util.Date;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.events.EventProfileSwitchChange; import info.nightscout.androidaps.events.EventProfileSwitchChange;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
import info.nightscout.androidaps.queue.commands.Command; import info.nightscout.androidaps.queue.commands.Command;
import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.LocalAlertUtils; import info.nightscout.utils.LocalAlertUtils;
@ -28,7 +29,7 @@ import info.nightscout.utils.LocalAlertUtils;
* Created by mike on 07.07.2016. * Created by mike on 07.07.2016.
*/ */
public class KeepAliveReceiver extends BroadcastReceiver { public class KeepAliveReceiver extends BroadcastReceiver {
private static Logger log = LoggerFactory.getLogger(KeepAliveReceiver.class); private static Logger log = LoggerFactory.getLogger(L.CORE);
public static final long STATUS_UPDATE_FREQUENCY = 15 * 60 * 1000L; public static final long STATUS_UPDATE_FREQUENCY = 15 * 60 * 1000L;
public static void cancelAlarm(Context context) { public static void cancelAlarm(Context context) {
@ -49,6 +50,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
checkPump(); checkPump();
FabricPrivacy.uploadDailyStats(); FabricPrivacy.uploadDailyStats();
if (L.isEnabled(L.CORE))
log.debug("KeepAlive received"); log.debug("KeepAlive received");
wl.release(); wl.release();
} }

View file

@ -11,14 +11,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.services.Intents;
public class NSAlarmReceiver extends BroadcastReceiver { public class NSAlarmReceiver extends BroadcastReceiver {
private static Logger log = LoggerFactory.getLogger(NSAlarmReceiver.class); private static Logger log = LoggerFactory.getLogger(L.CORE);
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {

View file

@ -15,10 +15,11 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.events.EventNetworkChange; import info.nightscout.androidaps.events.EventNetworkChange;
import info.nightscout.androidaps.logging.L;
public class NetworkChangeReceiver extends BroadcastReceiver { public class NetworkChangeReceiver extends BroadcastReceiver {
private static Logger log = LoggerFactory.getLogger(NetworkChangeReceiver.class); private static Logger log = LoggerFactory.getLogger(L.CORE);
@Override @Override
public void onReceive(final Context context, final Intent intent) { public void onReceive(final Context context, final Intent intent) {
@ -44,6 +45,7 @@ public class NetworkChangeReceiver extends BroadcastReceiver {
if (wifiInfo.getSupplicantState() == SupplicantState.COMPLETED) { if (wifiInfo.getSupplicantState() == SupplicantState.COMPLETED) {
event.ssid = wifiInfo.getSSID(); event.ssid = wifiInfo.getSSID();
} }
if (L.isEnabled(L.CORE))
log.debug("NETCHANGE: Wifi connected. SSID: " + event.ssid); log.debug("NETCHANGE: Wifi connected. SSID: " + event.ssid);
} }
} }
@ -51,9 +53,11 @@ public class NetworkChangeReceiver extends BroadcastReceiver {
if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) { if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
event.mobileConnected = true; event.mobileConnected = true;
event.roaming = activeNetwork.isRoaming(); event.roaming = activeNetwork.isRoaming();
if (L.isEnabled(L.CORE))
log.debug("NETCHANGE: Mobile connected. Roaming: " + event.roaming); log.debug("NETCHANGE: Mobile connected. Roaming: " + event.roaming);
} }
} else { } else {
if (L.isEnabled(L.CORE))
log.debug("NETCHANGE: Disconnected."); log.debug("NETCHANGE: Disconnected.");
} }

View file

@ -3,12 +3,10 @@ package info.nightscout.androidaps.tabs;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -17,6 +15,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.logging.L;
/** /**
* Created by mike on 30.05.2016. * Created by mike on 30.05.2016.
@ -27,7 +26,7 @@ public class TabPageAdapter extends FragmentPagerAdapter {
Context context; Context context;
private static Logger log = LoggerFactory.getLogger(TabPageAdapter.class); private static Logger log = LoggerFactory.getLogger(L.CORE);
public TabPageAdapter(FragmentManager fm, Context context) { public TabPageAdapter(FragmentManager fm, Context context) {
super(fm); super(fm);
@ -47,19 +46,19 @@ public class TabPageAdapter extends FragmentPagerAdapter {
@Override @Override
public void finishUpdate(ViewGroup container) { public void finishUpdate(ViewGroup container) {
try{ try {
super.finishUpdate(container); super.finishUpdate(container);
} catch (NullPointerException nullPointerException){ } catch (NullPointerException nullPointerException) {
System.out.println("Catch the NullPointerException in FragmentStatePagerAdapter.finishUpdate"); System.out.println("Catch the NullPointerException in FragmentStatePagerAdapter.finishUpdate");
} catch (IllegalStateException e){ } catch (IllegalStateException e) {
log.error(e.getMessage()); log.error("Unhandled exception", e);
} }
} }
@Override @Override
public CharSequence getPageTitle(int position) { public CharSequence getPageTitle(int position) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
if(preferences.getBoolean("short_tabtitles", false)){ if (preferences.getBoolean("short_tabtitles", false)) {
return visibleFragmentList.get(position).getNameShort(); return visibleFragmentList.get(position).getNameShort();
} }
return visibleFragmentList.get(position).getName(); return visibleFragmentList.get(position).getName();