PROFILE logging

This commit is contained in:
Milos Kozak 2018-07-29 15:37:28 +02:00
parent 54c83dc374
commit 188a9b6313
11 changed files with 292 additions and 205 deletions

View file

@ -23,8 +23,6 @@ public class Config {
public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER; public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
public static boolean logFunctionCalls = true;
public static boolean logPrefsChange = true;
public static boolean logConfigBuilder = true; public static boolean logConfigBuilder = true;
public static boolean logCongigBuilderActions = true; public static boolean logCongigBuilderActions = true;

View file

@ -48,6 +48,7 @@ import info.nightscout.androidaps.events.EventFeatureRunning;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Food.FoodPlugin; import info.nightscout.androidaps.plugins.Food.FoodPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
@ -62,7 +63,7 @@ import info.nightscout.utils.PasswordProtection;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private static Logger log = LoggerFactory.getLogger(MainActivity.class); private static Logger log = LoggerFactory.getLogger(L.CORE);
protected PowerManager.WakeLock mWakeLock; protected PowerManager.WakeLock mWakeLock;
@ -74,7 +75,7 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (Config.logFunctionCalls) if (L.isEnabled(L.CORE))
log.debug("onCreate"); log.debug("onCreate");
Iconify.with(new FontAwesomeModule()); Iconify.with(new FontAwesomeModule());
@ -134,6 +135,9 @@ public class MainActivity extends AppCompatActivity {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
if (L.isEnabled(L.CORE))
log.debug("onResume");
if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) { if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) {
Intent intent = new Intent(this, SetupWizardActivity.class); Intent intent = new Intent(this, SetupWizardActivity.class);
startActivity(intent); startActivity(intent);
@ -153,6 +157,8 @@ public class MainActivity extends AppCompatActivity {
@Override @Override
public void onDestroy() { public void onDestroy() {
if (L.isEnabled(L.CORE))
log.debug("onDestroy");
if (mWakeLock != null) if (mWakeLock != null)
if (mWakeLock.isHeld()) if (mWakeLock.isHeld())
mWakeLock.release(); mWakeLock.release();

View file

@ -24,13 +24,12 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.LoggerContext;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.services.Intents;
import info.nightscout.androidaps.data.ConstraintChecker; import info.nightscout.androidaps.data.ConstraintChecker;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Actions.ActionsFragment; import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin; import info.nightscout.androidaps.plugins.Careportal.CareportalPlugin;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
@ -43,6 +42,7 @@ import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlu
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver; import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin; import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
@ -77,13 +77,13 @@ import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
import info.nightscout.androidaps.receivers.DataReceiver; import info.nightscout.androidaps.receivers.DataReceiver;
import info.nightscout.androidaps.receivers.KeepAliveReceiver; import info.nightscout.androidaps.receivers.KeepAliveReceiver;
import info.nightscout.androidaps.receivers.NSAlarmReceiver; import info.nightscout.androidaps.receivers.NSAlarmReceiver;
import info.nightscout.androidaps.services.Intents;
import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.FabricPrivacy;
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
import io.fabric.sdk.android.Fabric; import io.fabric.sdk.android.Fabric;
public class MainApp extends Application { public class MainApp extends Application {
private static Logger log = LoggerFactory.getLogger(MainApp.class); private static Logger log = LoggerFactory.getLogger(L.CORE);
private static KeepAliveReceiver keepAliveReceiver; private static KeepAliveReceiver keepAliveReceiver;
private static Bus sBus; private static Bus sBus;
@ -107,6 +107,8 @@ public class MainApp extends Application {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
if (L.isEnabled(L.CORE))
log.debug("onCreate");
sInstance = this; sInstance = this;
sResources = getResources(); sResources = getResources();
sConstraintsChecker = new ConstraintChecker(this); sConstraintsChecker = new ConstraintChecker(this);
@ -119,7 +121,7 @@ public class MainApp extends Application {
Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION); Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION);
} }
} catch (Exception e) { } catch (Exception e) {
android.util.Log.e("ANDROIDAPS", "Error with Fabric init! " + e); log.error("Error with Fabric init! " + e);
} }
JodaTimeAndroid.init(this); JodaTimeAndroid.init(this);
@ -395,6 +397,8 @@ public class MainApp extends Application {
@Override @Override
public void onTerminate() { public void onTerminate() {
if (L.isEnabled(L.CORE))
log.debug("onTerminate");
super.onTerminate(); super.onTerminate();
if (sDatabaseHelper != null) { if (sDatabaseHelper != null) {
sDatabaseHelper.close(); sDatabaseHelper.close();

View file

@ -0,0 +1,103 @@
package info.nightscout.androidaps.logging;
import java.util.ArrayList;
import java.util.List;
import info.nightscout.utils.SP;
public class L {
public static class LogElement {
String name;
boolean defaultValue;
boolean enabled;
boolean requiresRestart = false;
LogElement(String name, boolean defaultValue) {
this.name = name;
this.defaultValue = defaultValue;
enabled = SP.getBoolean(getSPName(), defaultValue);
}
LogElement(String name, boolean defaultValue, boolean requiresRestart) {
this.name = name;
this.defaultValue = defaultValue;
this.requiresRestart = requiresRestart;
enabled = SP.getBoolean(getSPName(), defaultValue);
}
LogElement(boolean defaultValue) {
this.name = "NONEXISTING";
this.defaultValue = defaultValue;
enabled = defaultValue;
}
private String getSPName() {
return "log_" + name;
}
}
private static List<LogElement> logElements;
static {
initialize();
}
private static LogElement findByName(String name) {
for (LogElement element: logElements
) {
if (element.name.equals(name))
return element;
}
return new LogElement(false);
}
public static boolean isEnabled(String name) {
return findByName(name).enabled;
}
public static final String CORE = "CORE";
public static final String AUTOSENS = "AUTOSENS";
public static final String EVENTS = "EVENTS";
public static final String BGSOURCE = "BGSOURCE";
public static final String OVERVIEW = "OVERVIEW";
public static final String NOTIFICATION = "NOTIFICATION";
public static final String ALARM = "ALARM";
public static final String DATASERVICE = "DATASERVICE";
public static final String DATABASE = "DATABASE";
public static final String DATAFOOD = "DATAFOOD";
public static final String DATATREATMENTS = "DATATREATMENTS";
public static final String NSCLIENT = "NSCLIENT";
public static final String OBJECTIVES = "OBJECTIVES";
public static final String PUMP = "PUMP";
public static final String PUMPQUEUE = "PUMPQUEUE";
public static final String PUMPCOMM = "PUMPCOMM";
public static final String PUMPBTCOMM = "PUMPBTCOMM";
public static final String APS = "APS";
public static final String PROFILE = "PROFILE";
private static void initialize() {
logElements = new ArrayList<>();
logElements.add(new LogElement(CORE, true));
logElements.add(new LogElement(AUTOSENS, false));
logElements.add(new LogElement(EVENTS, false, true));
logElements.add(new LogElement(BGSOURCE, true));
logElements.add(new LogElement(OVERVIEW, true));
logElements.add(new LogElement(NOTIFICATION, true));
logElements.add(new LogElement(ALARM, false));
logElements.add(new LogElement(DATASERVICE, true));
logElements.add(new LogElement(DATABASE, true));
logElements.add(new LogElement(DATAFOOD, true));
logElements.add(new LogElement(DATATREATMENTS, true));
logElements.add(new LogElement(NSCLIENT, true));
logElements.add(new LogElement(OBJECTIVES, false));
logElements.add(new LogElement(PUMP, true));
logElements.add(new LogElement(PUMPQUEUE, true));
logElements.add(new LogElement(PUMPCOMM, true));
logElements.add(new LogElement(PUMPBTCOMM, false));
logElements.add(new LogElement(APS, true));
logElements.add(new LogElement(PROFILE, true));
}
}

View file

@ -120,7 +120,7 @@ public class ConfigBuilderPlugin extends PluginBase {
public void storeSettings(String from) { public void storeSettings(String from) {
if (pluginList != null) { if (pluginList != null) {
if (Config.logPrefsChange) if (Config.logConfigBuilder)
log.debug("Storing settings from: " + from); log.debug("Storing settings from: " + from);
for (PluginBase p : pluginList) { for (PluginBase p : pluginList) {
@ -152,7 +152,7 @@ public class ConfigBuilderPlugin extends PluginBase {
} }
private void loadSettings() { private void loadSettings() {
if (Config.logPrefsChange) if (Config.logConfigBuilder)
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();
@ -189,7 +189,7 @@ 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.logPrefsChange) if (Config.logConfigBuilder)
log.debug("Upgrading stored settings"); log.debug("Upgrading stored settings");
for (PluginBase p : pluginList) { for (PluginBase p : pluginList) {
log.debug("Processing " + p.getName()); log.debug("Processing " + p.getName());

View file

@ -25,20 +25,18 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.NumberPicker; import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
import info.nightscout.utils.TimeListEdit; import info.nightscout.utils.TimeListEdit;
public class LocalProfileFragment extends SubscriberFragment { public class LocalProfileFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(LocalProfileFragment.class);
NumberPicker diaView; NumberPicker diaView;
RadioButton mgdlView; RadioButton mgdlView;
RadioButton mmolView; RadioButton mmolView;
@ -81,8 +79,6 @@ public class LocalProfileFragment extends SubscriberFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
try {
PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription(); PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
View layout = inflater.inflate(R.layout.localprofile_fragment, container, false); View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia); diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
@ -141,7 +137,7 @@ public class LocalProfileFragment extends SubscriberFragment {
}); });
saveButton.setOnClickListener(view -> { saveButton.setOnClickListener(view -> {
if(!LocalProfilePlugin.getPlugin().isValidEditState()){ if (!LocalProfilePlugin.getPlugin().isValidEditState()) {
return; //Should not happen as saveButton should not be visible if not valid return; //Should not happen as saveButton should not be visible if not valid
} }
LocalProfilePlugin.getPlugin().storeSettings(); LocalProfilePlugin.getPlugin().storeSettings();
@ -149,12 +145,6 @@ public class LocalProfileFragment extends SubscriberFragment {
}); });
return layout; return layout;
} catch (Exception e) {
log.error("Unhandled exception: ", e);
FabricPrivacy.logException(e);
}
return null;
} }
public void doEdit() { public void doEdit() {
@ -203,7 +193,7 @@ public class LocalProfileFragment extends SubscriberFragment {
} }
//Show reset button iff data was edited //Show reset button iff data was edited
if(isEdited) { if (isEdited) {
resetButton.setVisibility(View.VISIBLE); resetButton.setVisibility(View.VISIBLE);
} else { } else {
resetButton.setVisibility(View.GONE); resetButton.setVisibility(View.GONE);

View file

@ -8,7 +8,6 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; 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;
@ -18,6 +17,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -26,7 +26,7 @@ import info.nightscout.utils.SP;
*/ */
public class LocalProfilePlugin extends PluginBase implements ProfileInterface { public class LocalProfilePlugin extends PluginBase implements ProfileInterface {
public static final String LOCAL_PROFILE = "LocalProfile"; public static final String LOCAL_PROFILE = "LocalProfile";
private static Logger log = LoggerFactory.getLogger(LocalProfilePlugin.class); private static Logger log = LoggerFactory.getLogger(L.PROFILE);
private static LocalProfilePlugin localProfilePlugin; private static LocalProfilePlugin localProfilePlugin;
@ -81,13 +81,13 @@ public class LocalProfilePlugin extends PluginBase implements ProfileInterface {
createAndStoreConvertedProfile(); createAndStoreConvertedProfile();
edited = false; edited = false;
if (Config.logPrefsChange) if (L.isEnabled(L.PROFILE))
log.debug("Storing settings: " + getRawProfile().getData().toString()); log.debug("Storing settings: " + getRawProfile().getData().toString());
MainApp.bus().post(new EventProfileStoreChanged()); MainApp.bus().post(new EventProfileStoreChanged());
} }
public synchronized void loadSettings() { public synchronized void loadSettings() {
if (Config.logPrefsChange) if (L.isEnabled(L.PROFILE))
log.debug("Loading stored settings"); log.debug("Loading stored settings");
mgdl = SP.getBoolean(LOCAL_PROFILE + "mgdl", false); mgdl = SP.getBoolean(LOCAL_PROFILE + "mgdl", false);

View file

@ -27,7 +27,6 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI; import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileGraph; import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileGraph;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.OKDialog; import info.nightscout.utils.OKDialog;
import static butterknife.OnItemSelected.Callback.NOTHING_SELECTED; import static butterknife.OnItemSelected.Callback.NOTHING_SELECTED;
@ -62,24 +61,22 @@ public class NSProfileFragment extends SubscriberFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.nsprofile_fragment, container, false); View view = inflater.inflate(R.layout.nsprofile_fragment, container, false);
unbinder = ButterKnife.bind(this, view); unbinder = ButterKnife.bind(this, view);
updateGUI(); updateGUI();
return view; return view;
} catch (Exception e) {
FabricPrivacy.logException(e);
}
return null;
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventNSProfileUpdateGUI ev) { public void onStatusEvent(final EventNSProfileUpdateGUI ev) {
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) if (activity != null)
activity.runOnUiThread(() -> { synchronized (NSProfileFragment.this) { updateGUI(); } }); activity.runOnUiThread(() -> {
synchronized (NSProfileFragment.this) {
updateGUI();
}
});
} }
@Override @Override

View file

@ -28,7 +28,7 @@ import info.nightscout.utils.SP;
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class NSProfilePlugin extends PluginBase implements ProfileInterface { public class NSProfilePlugin extends PluginBase implements ProfileInterface {
private static Logger log = LoggerFactory.getLogger(NSProfilePlugin.class); private static Logger log = LoggerFactory.getLogger(L.PROFILE);
private static NSProfilePlugin nsProfilePlugin; private static NSProfilePlugin nsProfilePlugin;
@ -78,7 +78,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
MainApp.bus().post(new EventProfileStoreChanged()); MainApp.bus().post(new EventProfileStoreChanged());
MainApp.bus().post(new EventNSProfileUpdateGUI()); MainApp.bus().post(new EventNSProfileUpdateGUI());
} }
if (L.isEnabled(L.NSCLIENT)) if (L.isEnabled(L.PROFILE))
log.debug("Received profileStore: " + activeProfile + " " + profile); log.debug("Received profileStore: " + activeProfile + " " + profile);
} catch (JSONException e) { } catch (JSONException e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
@ -87,16 +87,16 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
private void storeNSProfile() { private void storeNSProfile() {
SP.putString("profile", profile.getData().toString()); SP.putString("profile", profile.getData().toString());
if (Config.logPrefsChange) if (L.isEnabled(L.PROFILE))
log.debug("Storing profile"); log.debug("Storing profile");
} }
private void loadNSProfile() { private void loadNSProfile() {
if (Config.logPrefsChange) if (L.isEnabled(L.PROFILE))
log.debug("Loading stored profile"); log.debug("Loading stored profile");
String profileString = SP.getString("profile", null); String profileString = SP.getString("profile", null);
if (profileString != null) { if (profileString != null) {
if (Config.logPrefsChange) { if (L.isEnabled(L.PROFILE))
log.debug("Loaded profile: " + profileString); log.debug("Loaded profile: " + profileString);
try { try {
profile = new ProfileStore(new JSONObject(profileString)); profile = new ProfileStore(new JSONObject(profileString));
@ -104,16 +104,14 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
profile = null; profile = null;
} }
}
} else { } else {
if (Config.logPrefsChange) { if (L.isEnabled(L.PROFILE))
log.debug("Stored profile not found"); log.debug("Stored profile not found");
// force restart of nsclient to fetch profile // force restart of nsclient to fetch profile
Intent restartNSClient = new Intent(Intents.ACTION_RESTART); Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
} }
} }
}
@Nullable @Nullable
@Override @Override

View file

@ -26,12 +26,9 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
public class SimpleProfileFragment extends SubscriberFragment { public class SimpleProfileFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(SimpleProfileFragment.class);
EditText diaView; EditText diaView;
RadioButton mgdlView; RadioButton mgdlView;
RadioButton mmolView; RadioButton mmolView;
@ -46,7 +43,6 @@ public class SimpleProfileFragment extends SubscriberFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
try {
View layout = inflater.inflate(R.layout.simpleprofile_fragment, container, false); View layout = inflater.inflate(R.layout.simpleprofile_fragment, container, false);
diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia); diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl); mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
@ -127,11 +123,6 @@ public class SimpleProfileFragment extends SubscriberFragment {
targethighView.addTextChangedListener(textWatch); targethighView.addTextChangedListener(textWatch);
return layout; return layout;
} catch (Exception e) {
FabricPrivacy.logException(e);
}
return null;
} }
@Subscribe @Subscribe

View file

@ -9,7 +9,6 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; 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;
@ -19,13 +18,14 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
/** /**
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class SimpleProfilePlugin extends PluginBase implements ProfileInterface { public class SimpleProfilePlugin extends PluginBase implements ProfileInterface {
private static Logger log = LoggerFactory.getLogger(SimpleProfilePlugin.class); private static Logger log = LoggerFactory.getLogger(L.PROFILE);
private static SimpleProfilePlugin simpleProfilePlugin; private static SimpleProfilePlugin simpleProfilePlugin;
@ -58,7 +58,7 @@ public class SimpleProfilePlugin extends PluginBase implements ProfileInterface
} }
public void storeSettings() { public void storeSettings() {
if (Config.logPrefsChange) if (L.isEnabled(L.PROFILE))
log.debug("Storing settings"); log.debug("Storing settings");
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
SharedPreferences.Editor editor = settings.edit(); SharedPreferences.Editor editor = settings.edit();
@ -73,13 +73,13 @@ public class SimpleProfilePlugin extends PluginBase implements ProfileInterface
editor.apply(); editor.apply();
createConvertedProfile(); createConvertedProfile();
if (Config.logPrefsChange) if (L.isEnabled(L.PROFILE))
log.debug("Storing settings: " + getRawProfile().getData().toString()); log.debug("Storing settings: " + getRawProfile().getData().toString());
MainApp.bus().post(new EventProfileStoreChanged()); MainApp.bus().post(new EventProfileStoreChanged());
} }
private void loadSettings() { private void loadSettings() {
if (Config.logPrefsChange) if (L.isEnabled(L.PROFILE))
log.debug("Loading stored settings"); log.debug("Loading stored settings");
mgdl = SP.getBoolean("SimpleProfile" + "mgdl", true); mgdl = SP.getBoolean("SimpleProfile" + "mgdl", true);