2018-07-29 15:37:28 +02:00
|
|
|
package info.nightscout.androidaps.logging;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2019-02-26 20:38:27 +01:00
|
|
|
import info.nightscout.androidaps.utils.SP;
|
2018-07-29 15:37:28 +02:00
|
|
|
|
|
|
|
public class L {
|
|
|
|
|
|
|
|
public static class LogElement {
|
2018-08-02 15:19:13 +02:00
|
|
|
public String name;
|
2018-07-29 15:37:28 +02:00
|
|
|
boolean defaultValue;
|
2018-08-02 15:19:13 +02:00
|
|
|
public boolean enabled;
|
2018-07-29 15:37:28 +02:00
|
|
|
boolean requiresRestart = false;
|
|
|
|
|
|
|
|
LogElement(String name, boolean defaultValue) {
|
|
|
|
this.name = name;
|
|
|
|
this.defaultValue = defaultValue;
|
|
|
|
enabled = SP.getBoolean(getSPName(), defaultValue);
|
|
|
|
}
|
|
|
|
|
2018-07-30 17:04:43 +02:00
|
|
|
LogElement(String name, boolean defaultValue, boolean requiresRestart) {
|
2018-07-29 15:37:28 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-07-30 17:04:43 +02:00
|
|
|
public void setEnabled(boolean enabled) {
|
|
|
|
this.enabled = enabled;
|
|
|
|
SP.putBoolean(getSPName(), enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void resetToDefault() {
|
|
|
|
setEnabled(defaultValue);
|
|
|
|
}
|
2018-07-29 15:37:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static List<LogElement> logElements;
|
|
|
|
|
|
|
|
static {
|
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
private static LogElement findByName(String name) {
|
2018-07-30 17:04:43 +02:00
|
|
|
for (LogElement element : logElements) {
|
2018-07-29 15:37:28 +02:00
|
|
|
if (element.name.equals(name))
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
return new LogElement(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isEnabled(String name) {
|
|
|
|
return findByName(name).enabled;
|
|
|
|
}
|
|
|
|
|
2018-07-30 17:04:43 +02:00
|
|
|
public static List<LogElement> getLogElements() {
|
|
|
|
return logElements;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void resetToDefaults() {
|
|
|
|
for (LogElement element : logElements) {
|
|
|
|
element.resetToDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-29 15:37:28 +02:00
|
|
|
public static final String CORE = "CORE";
|
|
|
|
public static final String AUTOSENS = "AUTOSENS";
|
2019-04-18 19:33:23 +02:00
|
|
|
public static final String AUTOMATION = "AUTOMATION";
|
2018-07-29 15:37:28 +02:00
|
|
|
public static final String EVENTS = "EVENTS";
|
2019-04-15 15:19:19 +02:00
|
|
|
public static final String GLUCOSE = "GLUCOSE";
|
2018-07-29 15:37:28 +02:00
|
|
|
public static final String BGSOURCE = "BGSOURCE";
|
|
|
|
public static final String OVERVIEW = "OVERVIEW";
|
|
|
|
public static final String NOTIFICATION = "NOTIFICATION";
|
|
|
|
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";
|
2018-09-11 14:56:42 +02:00
|
|
|
public static final String CONSTRAINTS = "CONSTRAINTS";
|
2018-07-29 15:37:28 +02:00
|
|
|
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";
|
2018-07-30 15:46:20 +02:00
|
|
|
public static final String CONFIGBUILDER = "CONFIGBUILDER";
|
2018-08-03 12:32:10 +02:00
|
|
|
public static final String UI = "UI";
|
2018-09-19 15:26:58 +02:00
|
|
|
public static final String LOCATION = "LOCATION";
|
2018-10-13 16:50:47 +02:00
|
|
|
public static final String SMS = "SMS";
|
2018-07-29 15:37:28 +02:00
|
|
|
|
|
|
|
private static void initialize() {
|
|
|
|
logElements = new ArrayList<>();
|
2018-07-30 17:04:43 +02:00
|
|
|
logElements.add(new LogElement(APS, true));
|
2019-04-18 19:33:23 +02:00
|
|
|
logElements.add(new LogElement(AUTOMATION, true));
|
2018-11-02 23:24:57 +01:00
|
|
|
logElements.add(new LogElement(AUTOSENS, false));
|
2018-07-29 15:37:28 +02:00
|
|
|
logElements.add(new LogElement(BGSOURCE, true));
|
2019-04-15 15:19:19 +02:00
|
|
|
logElements.add(new LogElement(GLUCOSE, false));
|
2018-11-02 23:24:57 +01:00
|
|
|
logElements.add(new LogElement(CONFIGBUILDER, false));
|
2018-09-11 14:56:42 +02:00
|
|
|
logElements.add(new LogElement(CONSTRAINTS, true));
|
2018-07-30 17:04:43 +02:00
|
|
|
logElements.add(new LogElement(CORE, true));
|
2018-07-29 15:37:28 +02:00
|
|
|
logElements.add(new LogElement(DATABASE, true));
|
2018-11-02 23:24:57 +01:00
|
|
|
logElements.add(new LogElement(DATAFOOD, false));
|
2018-07-30 17:04:43 +02:00
|
|
|
logElements.add(new LogElement(DATASERVICE, true));
|
2018-07-29 15:37:28 +02:00
|
|
|
logElements.add(new LogElement(DATATREATMENTS, true));
|
2018-07-30 17:04:43 +02:00
|
|
|
logElements.add(new LogElement(EVENTS, false, true));
|
2018-09-19 15:26:58 +02:00
|
|
|
logElements.add(new LogElement(LOCATION, true));
|
2018-07-30 17:04:43 +02:00
|
|
|
logElements.add(new LogElement(NOTIFICATION, true));
|
2018-07-29 15:37:28 +02:00
|
|
|
logElements.add(new LogElement(NSCLIENT, true));
|
2018-07-30 17:04:43 +02:00
|
|
|
logElements.add(new LogElement(OVERVIEW, true));
|
|
|
|
logElements.add(new LogElement(PROFILE, true));
|
2018-07-29 15:37:28 +02:00
|
|
|
logElements.add(new LogElement(PUMP, true));
|
|
|
|
logElements.add(new LogElement(PUMPBTCOMM, false));
|
2018-07-30 17:04:43 +02:00
|
|
|
logElements.add(new LogElement(PUMPCOMM, true));
|
|
|
|
logElements.add(new LogElement(PUMPQUEUE, true));
|
2018-10-13 16:50:47 +02:00
|
|
|
logElements.add(new LogElement(SMS, true));
|
2018-08-03 12:32:10 +02:00
|
|
|
logElements.add(new LogElement(UI, true));
|
2018-07-29 15:37:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|