diff --git a/app/src/main/java/com/squareup/otto/LoggingBus.java b/app/src/main/java/com/squareup/otto/LoggingBus.java index 13b69c5029..f75cd5b8d3 100644 --- a/app/src/main/java/com/squareup/otto/LoggingBus.java +++ b/app/src/main/java/com/squareup/otto/LoggingBus.java @@ -10,8 +10,8 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.events.Event; +import info.nightscout.androidaps.logging.L; /** Logs events has they're being posted to and dispatched from the event bus. * @@ -19,7 +19,7 @@ import info.nightscout.androidaps.events.Event; * after 10s (after startup) and then again every 60s. * */ public class LoggingBus extends Bus { - private static Logger log = LoggerFactory.getLogger(Constants.EVENTS); + private static Logger log = LoggerFactory.getLogger(L.EVENTS); private static long everyMinute = System.currentTimeMillis() + 10 * 1000; private Map> event2Receiver = new HashMap<>(); diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index b5072b1e91..4d183476e9 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -27,22 +27,5 @@ public class Config { public static boolean logPrefsChange = true; public static boolean logConfigBuilder = true; public static boolean logCongigBuilderActions = true; - public static boolean logAutosensData = false; - public static boolean logEvents = false; - public static boolean logQueue = true; - public static boolean logBgSource = true; - public static boolean logOverview = true; - public static boolean logNotification = true; - public static boolean logAlarm = false; - public static boolean logDataService = true; - public static boolean logDataFood = true; - public static boolean logDataTreatments = true; - public static boolean logDatabase = true; - public static boolean logNsclient = true; - public static boolean logObjectives = false; - public static boolean logPump = true; - public static boolean logPumpComm = true; - public static boolean logPumpBtComm = false; - public static boolean logAps = true; } diff --git a/app/src/main/java/info/nightscout/androidaps/Constants.java b/app/src/main/java/info/nightscout/androidaps/Constants.java index 911b703d5d..ffe227dc1b 100644 --- a/app/src/main/java/info/nightscout/androidaps/Constants.java +++ b/app/src/main/java/info/nightscout/androidaps/Constants.java @@ -68,21 +68,4 @@ public class Constants { //SMS Communicator public static final long SMS_CONFIRM_TIMEOUT = T.mins(5).msecs(); - // logging - 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 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"; } diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 59fa8b3ad0..d4845a51dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -24,6 +24,7 @@ import java.io.File; import java.util.ArrayList; 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.db.DatabaseHelper; @@ -132,7 +133,7 @@ public class MainApp extends Application { engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile(); devBranch = BuildConfig.VERSION.contains("dev"); - sBus = Config.logEvents ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY); + sBus = L.isEnabled(L.EVENTS) ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY); registerLocalBroadcastReceiver(); diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index c0aff525ae..099c725036 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -27,7 +27,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.OverlappingIntervals; import info.nightscout.androidaps.data.Profile; @@ -42,12 +41,13 @@ import info.nightscout.androidaps.events.EventReloadTempBasalData; import info.nightscout.androidaps.events.EventReloadTreatmentData; import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.events.EventTempTargetChange; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData; +import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.utils.JsonHelper; -import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; import info.nightscout.utils.PercentageSplitter; import info.nightscout.utils.ToastUtils; @@ -60,7 +60,7 @@ import info.nightscout.utils.ToastUtils; * direct calls to the corresponding methods (eg. resetDatabases) should be done by a central service. */ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { - private static Logger log = LoggerFactory.getLogger(DatabaseHelper.class); + private static Logger log = LoggerFactory.getLogger(L.DATABASE); public static final String DATABASE_NAME = "AndroidAPSDb"; public static final String DATABASE_BGREADINGS = "BgReadings"; @@ -107,7 +107,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { @Override public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) { try { - log.info("onCreate"); + if (L.isEnabled(L.DATABASE)) + log.info("onCreate"); TableUtils.createTableIfNotExists(connectionSource, TempTarget.class); TableUtils.createTableIfNotExists(connectionSource, BgReading.class); TableUtils.createTableIfNotExists(connectionSource, DanaRHistoryRecord.class); @@ -325,15 +326,18 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { BgReading old = getDaoBgReadings().queryForId(bgReading.date); if (old == null) { getDaoBgReadings().create(bgReading); - log.debug("BG: New record from: " + from + " " + bgReading.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("BG: New record from: " + from + " " + bgReading.toString()); scheduleBgChange(bgReading); return true; } if (!old.isEqual(bgReading)) { - log.debug("BG: Similiar found: " + old.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("BG: Similiar found: " + old.toString()); old.copyFrom(bgReading); getDaoBgReadings().update(old); - log.debug("BG: Updating record from: " + from + " New data: " + old.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("BG: Updating record from: " + from + " New data: " + old.toString()); scheduleBgChange(bgReading); return false; } @@ -355,7 +359,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private static void scheduleBgChange(@Nullable final BgReading bgReading) { class PostRunnable implements Runnable { public void run() { - log.debug("Firing EventNewBg"); + if (L.isEnabled(L.DATABASE)) + log.debug("Firing EventNewBg"); MainApp.bus().post(new EventNewBG(bgReading)); scheduledBgPost = null; } @@ -387,7 +392,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { bgList = daoBgReadings.query(preparedQuery); } catch (SQLException e) { - log.debug(e.getMessage(), e); + log.error("Unhandled exception", e); } if (bgList != null && bgList.size() > 0) return bgList.get(0); @@ -595,7 +600,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { getDaoTempTargets().delete(old); // need to delete/create because date may change too old.copyFrom(tempTarget); getDaoTempTargets().create(old); - log.debug("TEMPTARGET: Updating record by date from: " + Source.getString(tempTarget.source) + " " + old.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("TEMPTARGET: Updating record by date from: " + Source.getString(tempTarget.source) + " " + old.toString()); scheduleTemporaryTargetChange(); return true; } @@ -614,20 +620,23 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { getDaoTempTargets().delete(old); // need to delete/create because date may change too old.copyFrom(tempTarget); getDaoTempTargets().create(old); - log.debug("TEMPTARGET: Updating record by _id from: " + Source.getString(tempTarget.source) + " " + old.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("TEMPTARGET: Updating record by _id from: " + Source.getString(tempTarget.source) + " " + old.toString()); scheduleTemporaryTargetChange(); return true; } } } getDaoTempTargets().create(tempTarget); - log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString()); scheduleTemporaryTargetChange(); return true; } if (tempTarget.source == Source.USER) { getDaoTempTargets().create(tempTarget); - log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("TEMPTARGET: New record from: " + Source.getString(tempTarget.source) + " " + tempTarget.toString()); scheduleTemporaryTargetChange(); return true; } @@ -649,7 +658,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private static void scheduleTemporaryTargetChange() { class PostRunnable implements Runnable { public void run() { - log.debug("Firing EventTempTargetChange"); + if (L.isEnabled(L.DATABASE)) + log.debug("Firing EventTempTargetChange"); MainApp.bus().post(new EventTempTargetChange()); scheduledTemTargetPost = null; } @@ -769,7 +779,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } else if (list.size() == 1) { DanaRHistoryRecord record = list.get(0); if (record._id == null || !record._id.equals(trJson.getString("_id"))) { - if (Config.logDatabase) + if (L.isEnabled(L.DATABASE)) log.debug("Updating _id in DanaR history database: " + trJson.getString("_id")); record._id = trJson.getString("_id"); getDaoDanaRHistory().update(record); @@ -799,11 +809,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { List trList = getDaoTemporaryBasal().query(preparedQuery); if (trList.size() > 0) { // do nothing, pump history record cannot be changed - log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("TEMPBASAL: Already exists from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); return false; } getDaoTemporaryBasal().create(tempBasal); - log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); updateEarliestDataChange(tempBasal.date); scheduleTemporaryBasalChange(); return true; @@ -820,7 +832,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too old.copyFrom(tempBasal); getDaoTemporaryBasal().create(old); - log.debug("TEMPBASAL: Updating record by date from: " + Source.getString(tempBasal.source) + " " + old.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("TEMPBASAL: Updating record by date from: " + Source.getString(tempBasal.source) + " " + old.toString()); updateEarliestDataChange(oldDate); updateEarliestDataChange(old.date); scheduleTemporaryBasalChange(); @@ -842,7 +855,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too old.copyFrom(tempBasal); getDaoTemporaryBasal().create(old); - log.debug("TEMPBASAL: Updating record by _id from: " + Source.getString(tempBasal.source) + " " + old.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("TEMPBASAL: Updating record by _id from: " + Source.getString(tempBasal.source) + " " + old.toString()); updateEarliestDataChange(oldDate); updateEarliestDataChange(old.date); scheduleTemporaryBasalChange(); @@ -851,14 +865,16 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } } getDaoTemporaryBasal().create(tempBasal); - log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); updateEarliestDataChange(tempBasal.date); scheduleTemporaryBasalChange(); return true; } if (tempBasal.source == Source.USER) { getDaoTemporaryBasal().create(tempBasal); - log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("TEMPBASAL: New record from: " + Source.getString(tempBasal.source) + " " + tempBasal.toString()); updateEarliestDataChange(tempBasal.date); scheduleTemporaryBasalChange(); return true; @@ -898,7 +914,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private static void scheduleTemporaryBasalChange() { class PostRunnable implements Runnable { public void run() { - log.debug("Firing EventTempBasalChange"); + if (L.isEnabled(L.DATABASE)) + log.debug("Firing EventTempBasalChange"); MainApp.bus().post(new EventReloadTempBasalData()); MainApp.bus().post(new EventTempBasalChange()); if (earliestDataChange != null) @@ -990,7 +1007,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { public void deleteTempBasalById(String _id) { TemporaryBasal stored = findTempBasalById(_id); if (stored != null) { - log.debug("TEMPBASAL: Removing TempBasal record from database: " + stored.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("TEMPBASAL: Removing TempBasal record from database: " + stored.toString()); delete(stored); updateEarliestDataChange(stored.date); scheduleTemporaryBasalChange(); @@ -1036,7 +1054,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { return false; } getDaoExtendedBolus().create(extendedBolus); - log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString()); updateEarliestDataChange(extendedBolus.date); scheduleExtendedBolusChange(); return true; @@ -1049,7 +1068,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { getDaoExtendedBolus().delete(old); // need to delete/create because date may change too old.copyFrom(extendedBolus); getDaoExtendedBolus().create(old); - log.debug("EXTENDEDBOLUS: Updating record by date from: " + Source.getString(extendedBolus.source) + " " + old.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("EXTENDEDBOLUS: Updating record by date from: " + Source.getString(extendedBolus.source) + " " + old.toString()); updateEarliestDataChange(oldDate); updateEarliestDataChange(old.date); scheduleExtendedBolusChange(); @@ -1071,7 +1091,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { getDaoExtendedBolus().delete(old); // need to delete/create because date may change too old.copyFrom(extendedBolus); getDaoExtendedBolus().create(old); - log.debug("EXTENDEDBOLUS: Updating record by _id from: " + Source.getString(extendedBolus.source) + " " + old.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("EXTENDEDBOLUS: Updating record by _id from: " + Source.getString(extendedBolus.source) + " " + old.toString()); updateEarliestDataChange(oldDate); updateEarliestDataChange(old.date); scheduleExtendedBolusChange(); @@ -1080,14 +1101,16 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } } getDaoExtendedBolus().create(extendedBolus); - log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString()); updateEarliestDataChange(extendedBolus.date); scheduleExtendedBolusChange(); return true; } if (extendedBolus.source == Source.USER) { getDaoExtendedBolus().create(extendedBolus); - log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("EXTENDEDBOLUS: New record from: " + Source.getString(extendedBolus.source) + " " + extendedBolus.toString()); updateEarliestDataChange(extendedBolus.date); scheduleExtendedBolusChange(); return true; @@ -1127,7 +1150,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { public void deleteExtendedBolusById(String _id) { ExtendedBolus stored = findExtendedBolusById(_id); if (stored != null) { - log.debug("EXTENDEDBOLUS: Removing ExtendedBolus record from database: " + stored.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("EXTENDEDBOLUS: Removing ExtendedBolus record from database: " + stored.toString()); delete(stored); updateEarliestDataChange(stored.date); scheduleExtendedBolusChange(); @@ -1180,7 +1204,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private static void scheduleExtendedBolusChange() { class PostRunnable implements Runnable { public void run() { - log.debug("Firing EventExtendedBolusChange"); + if (L.isEnabled(L.DATABASE)) + log.debug("Firing EventExtendedBolusChange"); MainApp.bus().post(new EventReloadTreatmentData(new EventExtendedBolusChange())); if (earliestDataChange != null) MainApp.bus().post(new EventNewHistoryData(earliestDataChange)); @@ -1320,11 +1345,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { if (list.size() == 1) { CareportalEvent record = list.get(0); - if (Config.logDatabase) + if (L.isEnabled(L.DATABASE)) log.debug("Removing CareportalEvent record from database: " + record.log()); delete(record); } else { - if (Config.logDatabase) + if (L.isEnabled(L.DATABASE)) log.debug("CareportalEvent not found database: " + _id); } } catch (SQLException e) { @@ -1344,12 +1369,12 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { if (list.size() == 0) { careportalEvent = new CareportalEvent(); careportalEvent.source = Source.NIGHTSCOUT; - if (Config.logDatabase) + if (L.isEnabled(L.DATABASE)) log.debug("Adding CareportalEvent record to database: " + trJson.toString()); // Record does not exists. add } else if (list.size() == 1) { careportalEvent = list.get(0); - if (Config.logDatabase) + if (L.isEnabled(L.DATABASE)) log.debug("Updating CareportalEvent record in database: " + trJson.toString()); } else { log.error("Something went wrong"); @@ -1368,7 +1393,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private static void scheduleCareportalEventChange() { class PostRunnable implements Runnable { public void run() { - log.debug("Firing scheduleCareportalEventChange"); + if (L.isEnabled(L.DATABASE)) + log.debug("Firing scheduleCareportalEventChange"); MainApp.bus().post(new EventCareportalEventChange()); scheduledCareportalEventPost = null; } @@ -1414,7 +1440,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { profileSwitch.profileName = old.profileName; // preserver profileName to prevent multiple CPP extension getDaoProfileSwitch().delete(old); // need to delete/create because date may change too getDaoProfileSwitch().create(profileSwitch); - log.debug("PROFILESWITCH: Updating record by date from: " + Source.getString(profileSwitch.source) + " " + old.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("PROFILESWITCH: Updating record by date from: " + Source.getString(profileSwitch.source) + " " + old.toString()); scheduleProfileSwitchChange(); return true; } @@ -1433,7 +1460,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { getDaoProfileSwitch().delete(old); // need to delete/create because date may change too old.copyFrom(profileSwitch); getDaoProfileSwitch().create(old); - log.debug("PROFILESWITCH: Updating record by _id from: " + Source.getString(profileSwitch.source) + " " + old.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("PROFILESWITCH: Updating record by _id from: " + Source.getString(profileSwitch.source) + " " + old.toString()); scheduleProfileSwitchChange(); return true; } @@ -1442,13 +1470,15 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { // look for already added percentage from NS profileSwitch.profileName = PercentageSplitter.pureName(profileSwitch.profileName); getDaoProfileSwitch().create(profileSwitch); - log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString()); scheduleProfileSwitchChange(); return true; } if (profileSwitch.source == Source.USER) { getDaoProfileSwitch().create(profileSwitch); - log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("PROFILESWITCH: New record from: " + Source.getString(profileSwitch.source) + " " + profileSwitch.toString()); scheduleProfileSwitchChange(); return true; } @@ -1470,7 +1500,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private static void scheduleProfileSwitchChange() { class PostRunnable implements Runnable { public void run() { - log.debug("Firing EventProfileSwitchChange"); + if (L.isEnabled(L.DATABASE)) + log.debug("Firing EventProfileSwitchChange"); MainApp.bus().post(new EventReloadProfileSwitchData()); MainApp.bus().post(new EventProfileSwitchChange()); scheduledProfileSwitchEventPost = null; @@ -1520,15 +1551,18 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { Profile profile = store.getSpecificProfile(profileSwitch.profileName); if (profile != null) { profileSwitch.profileJson = profile.getData().toString(); - log.debug("Profile switch prefilled with JSON from local store"); + if (L.isEnabled(L.DATABASE)) + log.debug("Profile switch prefilled with JSON from local store"); // Update data in NS NSUpload.updateProfileSwitch(profileSwitch); } else { - log.debug("JSON for profile switch doesn't exist. Ignoring: " + trJson.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("JSON for profile switch doesn't exist. Ignoring: " + trJson.toString()); return; } } else { - log.debug("Store for profile switch doesn't exist. Ignoring: " + trJson.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("Store for profile switch doesn't exist. Ignoring: " + trJson.toString()); return; } } @@ -1543,7 +1577,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { public void deleteProfileSwitchById(String _id) { ProfileSwitch stored = findProfileSwitchById(_id); if (stored != null) { - log.debug("PROFILESWITCH: Removing ProfileSwitch record from database: " + stored.toString()); + if (L.isEnabled(L.DATABASE)) + log.debug("PROFILESWITCH: Removing ProfileSwitch record from database: " + stored.toString()); delete(stored); scheduleTemporaryTargetChange(); } diff --git a/app/src/main/java/info/nightscout/utils/BundleLogger.java b/app/src/main/java/info/nightscout/androidaps/logging/BundleLogger.java similarity index 90% rename from app/src/main/java/info/nightscout/utils/BundleLogger.java rename to app/src/main/java/info/nightscout/androidaps/logging/BundleLogger.java index ba6ffff869..b559c7af7e 100644 --- a/app/src/main/java/info/nightscout/utils/BundleLogger.java +++ b/app/src/main/java/info/nightscout/androidaps/logging/BundleLogger.java @@ -1,4 +1,4 @@ -package info.nightscout.utils; +package info.nightscout.androidaps.logging; import android.os.Bundle; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java index d469faa568..35effd4249 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java @@ -6,19 +6,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; -import java.util.Date; import java.util.List; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.DetailedBolusInfo; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 08.08.2017. */ public class DetailedBolusInfoStorage { - private static Logger log = LoggerFactory.getLogger(Constants.PUMP); + private static Logger log = LoggerFactory.getLogger(L.PUMP); private static List store = new ArrayList<>(); public static synchronized void add(DetailedBolusInfo detailedBolusInfo) { @@ -31,7 +29,7 @@ public class DetailedBolusInfoStorage { DetailedBolusInfo found = null; for (int i = 0; i < store.size(); i++) { long infoTime = store.get(i).date; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Existing bolus info: " + store.get(i)); if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { found = store.get(i); @@ -45,7 +43,7 @@ public class DetailedBolusInfoStorage { for (int i = 0; i < store.size(); i++) { long infoTime = store.get(i).date; if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Removing bolus info: " + store.get(i)); store.remove(i); break; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java index 10ec7e1fb0..df62fd3eb9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java @@ -7,7 +7,6 @@ import java.util.ArrayList; import java.util.List; import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.interfaces.Constraint; @@ -16,6 +15,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConstraintsObjectives.events.EventObjectivesSaved; import info.nightscout.androidaps.plugins.ConstraintsObjectives.objectives.Objective; @@ -33,7 +33,7 @@ import info.nightscout.utils.SP; * Created by mike on 05.08.2016. */ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface { - private static Logger log = LoggerFactory.getLogger(Constants.OBJECTIVES); + private static Logger log = LoggerFactory.getLogger(L.OBJECTIVES); private static ObjectivesPlugin objectivesPlugin; @@ -95,7 +95,7 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface SP.putBoolean("Objectives" + "bgIsAvailableInNS", bgIsAvailableInNS); SP.putBoolean("Objectives" + "pumpStatusIsAvailableInNS", pumpStatusIsAvailableInNS); SP.putString("Objectives" + "manualEnacts", Integer.toString(manualEnacts)); - if (Config.logObjectives) + if (L.isEnabled(L.OBJECTIVES)) log.debug("Objectives stored"); MainApp.bus().post(new EventObjectivesSaved()); } @@ -108,7 +108,7 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface } catch (Exception e) { log.error("Unhandled exception", e); } - if (Config.logObjectives) + if (L.isEnabled(L.OBJECTIVES)) log.debug("Objectives loaded"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodService.java index f1e4159248..c864c623db 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Food/FoodService.java @@ -27,21 +27,20 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.ICallback; import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.EventFoodDatabaseChanged; import info.nightscout.androidaps.events.EventNsFood; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 24.09.2017. */ public class FoodService extends OrmLiteBaseService { - private Logger log = LoggerFactory.getLogger(Constants.DATAFOOD); + private Logger log = LoggerFactory.getLogger(L.DATAFOOD); private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor(); private static ScheduledFuture scheduledFoodEventPost = null; @@ -112,7 +111,7 @@ public class FoodService extends OrmLiteBaseService { public void onCreate() { super.onCreate(); try { - if (Config.logDataFood) + if (L.isEnabled(L.DATAFOOD)) log.info("onCreate"); TableUtils.createTableIfNotExists(this.getConnectionSource(), Food.class); } catch (SQLException e) { @@ -125,7 +124,7 @@ public class FoodService extends OrmLiteBaseService { if (oldVersion == 7 && newVersion == 8) { log.debug("Upgrading database from v7 to v8"); } else { - if (Config.logDataFood) + if (L.isEnabled(L.DATAFOOD)) log.info("onUpgrade"); // this.resetFood(); } @@ -165,7 +164,7 @@ public class FoodService extends OrmLiteBaseService { class PostRunnable implements Runnable { public void run() { - if (Config.logDataFood) + if (L.isEnabled(L.DATAFOOD)) log.debug("Firing EventFoodChange"); MainApp.bus().post(event); callback.setPost(null); @@ -276,7 +275,7 @@ public class FoodService extends OrmLiteBaseService { public void deleteByNSId(String _id) throws SQLException { Food stored = this.findByNSId(_id); if (stored != null) { - if (Config.logDataFood) + if (L.isEnabled(L.DATAFOOD)) log.debug("Removing Food record from database: " + stored.toString()); this.delete(stored); } @@ -330,7 +329,7 @@ public class FoodService extends OrmLiteBaseService { public void createOrUpdate(Food food) { try { this.getDao().createOrUpdate(food); - if (Config.logDataFood) + if (L.isEnabled(L.DATAFOOD)) log.debug("Created or Updated: " + food.toString()); } catch (SQLException e) { log.error("Unable to createOrUpdate Food", e); @@ -341,7 +340,7 @@ public class FoodService extends OrmLiteBaseService { public void create(Food food) { try { this.getDao().create(food); - if (Config.logDataFood) + if (L.isEnabled(L.DATAFOOD)) log.debug("New record: " + food.toString()); } catch (SQLException e) { log.error("Unable to create Food", e); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java index 95a3976155..499984e3dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java @@ -12,6 +12,7 @@ import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults; import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries; @@ -26,7 +27,7 @@ import info.nightscout.utils.SP; */ public class AutosensData implements DataPointWithLabelInterface { - private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); + private static Logger log = LoggerFactory.getLogger(L.AUTOSENS); public void setChartTime(long chartTime) { this.chartTime = chartTime; @@ -48,7 +49,8 @@ public class AutosensData implements DataPointWithLabelInterface { double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits()); double ic = profile.getIc(t.date); min5minCarbImpact = t.carbs / (maxAbsorptionHours * 60 / 5) * sens / ic; - log.debug("Min 5m carbs impact for " + carbs + "g @" + new Date(t.date).toLocaleString() + " for " + maxAbsorptionHours + "h calculated to " + min5minCarbImpact + " ISF: " + sens + " IC: " + ic); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Min 5m carbs impact for " + carbs + "g @" + new Date(t.date).toLocaleString() + " for " + maxAbsorptionHours + "h calculated to " + min5minCarbImpact + " ISF: " + sens + " IC: " + ic); } else { min5minCarbImpact = SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact); } @@ -107,7 +109,8 @@ public class AutosensData implements DataPointWithLabelInterface { activeCarbsList.remove(i--); if (c.remaining > 0) cob -= c.remaining; - log.debug("Removing carbs at " + new Date(toTime).toLocaleString() + " + after " + maxAbsorptionHours + "h :" + new Date(c.time).toLocaleString()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Removing carbs at " + new Date(toTime).toLocaleString() + " + after " + maxAbsorptionHours + "h :" + new Date(c.time).toLocaleString()); } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensResult.java index 92a5ad1217..7bd01fa7b2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensResult.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensResult.java @@ -5,13 +5,13 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 06.01.2017. */ public class AutosensResult { - private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); + private static Logger log = LoggerFactory.getLogger(L.AUTOSENS); //default values to show when autosens algorithm is not called public double ratio = 1d; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java index daabef245a..824a0eda9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java @@ -1,7 +1,6 @@ package info.nightscout.androidaps.plugins.IobCobCalculator; import android.os.SystemClock; -import android.provider.SyncStateContract; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.util.LongSparseArray; @@ -16,7 +15,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -33,6 +31,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin; @@ -49,7 +48,7 @@ import static info.nightscout.utils.DateUtil.now; */ public class IobCobCalculatorPlugin extends PluginBase { - private Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); + private Logger log = LoggerFactory.getLogger(L.AUTOSENS); private static IobCobCalculatorPlugin plugin = null; @@ -112,13 +111,15 @@ public class IobCobCalculatorPlugin extends PluginBase { //log.debug("Locking getBucketedData"); synchronized (dataLock) { if (bucketed_data == null) { - log.debug("No bucketed data available"); + if (L.isEnabled(L.AUTOSENS)) + log.debug("No bucketed data available"); return null; } int index = indexNewerThan(fromTime); if (index > -1) { List part = bucketed_data.subList(0, index); - log.debug("Bucketed data striped off: " + part.size() + "/" + bucketed_data.size()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Bucketed data striped off: " + part.size() + "/" + bucketed_data.size()); return part; } } @@ -144,7 +145,8 @@ public class IobCobCalculatorPlugin extends PluginBase { void loadBgData(long now) { long start = (long) (now - 60 * 60 * 1000L * (24 + dia)); bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, now, false); - log.debug("BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(now)); + if (L.isEnabled(L.AUTOSENS)) + log.debug("BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(now)); } private boolean isAbout5minData() { @@ -160,13 +162,15 @@ public class IobCobCalculatorPlugin extends PluginBase { totalDiff += diff; if (diff > 30 * 1000 && diff < 270 * 1000) { // 0:30 - 4:30 log.debug("Interval detection: values: " + bgReadings.size() + " diff: " + (diff / 1000) + "sec is5minData: " + false); - return false; + if (L.isEnabled(L.AUTOSENS)) + return false; } } double intervals = totalDiff / (5 * 60 * 1000d); double variability = Math.abs(intervals - Math.round(intervals)); boolean is5mindata = variability < 0.02; - log.debug("Interval detection: values: " + bgReadings.size() + " variability: " + variability + " is5minData: " + is5mindata); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Interval detection: values: " + bgReadings.size() + " variability: " + variability + " is5minData: " + is5mindata); return is5mindata; } } @@ -293,7 +297,8 @@ public class IobCobCalculatorPlugin extends PluginBase { //log.error("***** Average"); } } - log.debug("Bucketed data created. Size: " + bucketed_data.size()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Bucketed data created. Size: " + bucketed_data.size()); } public long calculateDetectionStart(long from, boolean limitDataToOldestAvailable) { @@ -306,7 +311,8 @@ public class IobCobCalculatorPlugin extends PluginBase { if (limitDataToOldestAvailable) { getBGDataFrom = Math.max(oldestDataAvailable, (long) (from - T.hours(1).msecs() * (24 + dia))); if (getBGDataFrom == oldestDataAvailable) - log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString()); } else getBGDataFrom = (long) (from - T.hours(1).msecs() * (24 + dia)); return getBGDataFrom; @@ -413,12 +419,14 @@ public class IobCobCalculatorPlugin extends PluginBase { @Nullable public AutosensData getLastAutosensDataSynchronized(String reason) { if (thread != null && thread.isAlive()) { - log.debug("AUTOSENSDATA is waiting for calculation thread: " + reason); + if (L.isEnabled(L.AUTOSENS)) + log.debug("AUTOSENSDATA is waiting for calculation thread: " + reason); try { thread.join(5000); } catch (InterruptedException ignored) { } - log.debug("AUTOSENSDATA finished waiting for calculation thread: " + reason); + if (L.isEnabled(L.AUTOSENS)) + log.debug("AUTOSENSDATA finished waiting for calculation thread: " + reason); } synchronized (dataLock) { return getLastAutosensData(reason); @@ -456,7 +464,8 @@ public class IobCobCalculatorPlugin extends PluginBase { @Nullable public AutosensData getLastAutosensData(String reason) { if (autosensDataTable.size() < 1) { - log.debug("AUTOSENSDATA null: autosensDataTable empty (" + reason + ")"); + if (L.isEnabled(L.AUTOSENS)) + log.debug("AUTOSENSDATA null: autosensDataTable empty (" + reason + ")"); return null; } AutosensData data; @@ -470,10 +479,12 @@ public class IobCobCalculatorPlugin extends PluginBase { return null; } if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) { - log.debug("AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time)); + if (L.isEnabled(L.AUTOSENS)) + log.debug("AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time)); return null; } else { - log.debug("AUTOSENSDATA (" + reason + ") " + data.toString()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("AUTOSENSDATA (" + reason + ") " + data.toString()); return data; } } @@ -535,7 +546,8 @@ public class IobCobCalculatorPlugin extends PluginBase { @SuppressWarnings("unused") public void onEventAppInitialized(EventAppInitialized ev) { if (this != getPlugin()) { - log.debug("Ignoring event for non default instance"); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Ignoring event for non default instance"); return; } runCalculation("onEventAppInitialized", System.currentTimeMillis(), true, true, ev); @@ -545,7 +557,8 @@ public class IobCobCalculatorPlugin extends PluginBase { @SuppressWarnings("unused") public void onEventNewBG(EventNewBG ev) { if (this != getPlugin()) { - log.debug("Ignoring event for non default instance"); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Ignoring event for non default instance"); return; } stopCalculation("onEventNewBG"); @@ -555,16 +568,19 @@ public class IobCobCalculatorPlugin extends PluginBase { public void stopCalculation(String from) { if (thread != null && thread.getState() != Thread.State.TERMINATED) { stopCalculationTrigger = true; - log.debug("Stopping calculation thread: " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Stopping calculation thread: " + from); while (thread.getState() != Thread.State.TERMINATED) { SystemClock.sleep(100); } - log.debug("Calculation thread stopped: " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Calculation thread stopped: " + from); } } public void runCalculation(String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) { - log.debug("Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end)); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end)); if (thread == null || thread.getState() == Thread.State.TERMINATED) { if (SensitivityOref1Plugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) thread = new IobCobOref1Thread(this, from, end, bgDataReload, limitDataToOldestAvailable, cause); @@ -577,7 +593,8 @@ public class IobCobCalculatorPlugin extends PluginBase { @Subscribe public void onNewProfile(EventNewBasalProfile ev) { if (this != getPlugin()) { - log.debug("Ignoring event for non default instance"); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Ignoring event for non default instance"); return; } if (MainApp.getConfigBuilder() == null) @@ -591,7 +608,8 @@ public class IobCobCalculatorPlugin extends PluginBase { } stopCalculation("onNewProfile"); synchronized (dataLock) { - log.debug("Invalidating cached data because of new profile. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Invalidating cached data because of new profile. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); iobTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>(); } @@ -601,7 +619,8 @@ public class IobCobCalculatorPlugin extends PluginBase { @Subscribe public void onEventPreferenceChange(EventPreferenceChange ev) { if (this != getPlugin()) { - log.debug("Ignoring event for non default instance"); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Ignoring event for non default instance"); return; } if (ev.isChanged(R.string.key_openapsama_autosens_period) || @@ -614,7 +633,8 @@ public class IobCobCalculatorPlugin extends PluginBase { ) { stopCalculation("onEventPreferenceChange"); synchronized (dataLock) { - log.debug("Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); iobTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>(); } @@ -625,12 +645,14 @@ public class IobCobCalculatorPlugin extends PluginBase { @Subscribe public void onEventConfigBuilderChange(EventConfigBuilderChange ev) { if (this != getPlugin()) { - log.debug("Ignoring event for non default instance"); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Ignoring event for non default instance"); return; } stopCalculation("onEventConfigBuilderChange"); synchronized (dataLock) { - log.debug("Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records"); iobTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>(); } @@ -641,7 +663,8 @@ public class IobCobCalculatorPlugin extends PluginBase { @Subscribe public void onEventNewHistoryData(EventNewHistoryData ev) { if (this != getPlugin()) { - log.debug("Ignoring event for non default instance"); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Ignoring event for non default instance"); return; } //log.debug("Locking onNewHistoryData"); @@ -649,10 +672,11 @@ public class IobCobCalculatorPlugin extends PluginBase { synchronized (dataLock) { // clear up 5 min back for proper COB calculation long time = ev.time - 5 * 60 * 1000L; - log.debug("Invalidating cached data to: " + new Date(time).toLocaleString()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Invalidating cached data to: " + new Date(time).toLocaleString()); for (int index = iobTable.size() - 1; index >= 0; index--) { if (iobTable.keyAt(index) > time) { - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Removing from iobTable: " + new Date(iobTable.keyAt(index)).toLocaleString()); iobTable.removeAt(index); } else { @@ -661,7 +685,7 @@ public class IobCobCalculatorPlugin extends PluginBase { } for (int index = autosensDataTable.size() - 1; index >= 0; index--) { if (autosensDataTable.keyAt(index) > time) { - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Removing from autosensDataTable: " + new Date(autosensDataTable.keyAt(index)).toLocaleString()); autosensDataTable.removeAt(index); } else { @@ -670,7 +694,7 @@ public class IobCobCalculatorPlugin extends PluginBase { } for (int index = basalDataTable.size() - 1; index >= 0; index--) { if (basalDataTable.keyAt(index) > time) { - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Removing from basalDataTable: " + new Date(basalDataTable.keyAt(index)).toLocaleString()); basalDataTable.removeAt(index); } else { @@ -684,7 +708,8 @@ public class IobCobCalculatorPlugin extends PluginBase { public void clearCache() { synchronized (dataLock) { - log.debug("Clearing cached data."); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Clearing cached data."); iobTable = new LongSparseArray<>(); autosensDataTable = new LongSparseArray<>(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobOref1Thread.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobOref1Thread.java index a51e0e95f4..30d087d71c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobOref1Thread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobOref1Thread.java @@ -17,7 +17,6 @@ import java.util.GregorianCalendar; import java.util.List; import info.nightscout.androidaps.BuildConfig; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -26,6 +25,7 @@ import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.events.Event; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress; import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults; @@ -43,7 +43,7 @@ import static java.util.Calendar.MINUTE; */ public class IobCobOref1Thread extends Thread { - private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); + private static Logger log = LoggerFactory.getLogger(L.AUTOSENS); private final Event cause; private IobCobCalculatorPlugin iobCobCalculatorPlugin; @@ -72,13 +72,16 @@ public class IobCobOref1Thread extends Thread { public final void run() { mWakeLock.acquire(); try { - log.debug("AUTOSENSDATA thread started: " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("AUTOSENSDATA thread started: " + from); if (MainApp.getConfigBuilder() == null) { - log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from); return; // app still initializing } if (!MainApp.getConfigBuilder().isProfileValid("IobCobThread")) { - log.debug("Aborting calculation thread (No profile): " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Aborting calculation thread (No profile): " + from); return; // app still initializing } //log.debug("Locking calculateSensitivityData"); @@ -94,12 +97,14 @@ public class IobCobOref1Thread extends Thread { LongSparseArray autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); if (bucketed_data == null || bucketed_data.size() < 3) { - log.debug("Aborting calculation thread (No bucketed data available): " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Aborting calculation thread (No bucketed data available): " + from); return; } long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date); - log.debug("Prev data time: " + new Date(prevDataTime).toLocaleString()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Prev data time: " + new Date(prevDataTime).toLocaleString()); AutosensData previous = autosensDataTable.get(prevDataTime); // start from oldest to be able sub cob for (int i = bucketed_data.size() - 4; i >= 0; i--) { @@ -108,7 +113,8 @@ public class IobCobOref1Thread extends Thread { if (iobCobCalculatorPlugin.stopCalculationTrigger) { iobCobCalculatorPlugin.stopCalculationTrigger = false; - log.debug("Aborting calculation thread (trigger): " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Aborting calculation thread (trigger): " + from); return; } // check if data already exists @@ -125,11 +131,12 @@ public class IobCobOref1Thread extends Thread { Profile profile = MainApp.getConfigBuilder().getProfile(bgTime); if (profile == null) { - log.debug("Aborting calculation thread (no profile): " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Aborting calculation thread (no profile): " + from); return; // profile not set yet } - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Processing calculation thread: " + from + " (" + i + "/" + bucketed_data.size() + ")"); double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits()); @@ -171,7 +178,7 @@ public class IobCobOref1Thread extends Thread { AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago); if (hourAgoData != null) { int initialIndex = autosensDataTable.indexOfKey(hourAgoData.time); - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(">>>>> bucketed_data.size()=" + bucketed_data.size() + " i=" + i + "hourAgoData=" + hourAgoData.toString()); int past = 1; try { @@ -187,7 +194,7 @@ public class IobCobOref1Thread extends Thread { minDeviation = ad.avgDeviation; } - //if (Config.logAutosensData) + //if (Config.isEnabled(L.AUTOSENS)) // log.debug("Deviations: " + new Date(bgTime) + new Date(ad.time) + " avgDeviation=" + avgDeviation + " deviationSlope=" + deviationSlope + " slopeFromMaxDeviation=" + slopeFromMaxDeviation + " slopeFromMinDeviation=" + slopeFromMinDeviation); } } catch (Exception e) { @@ -340,13 +347,13 @@ public class IobCobOref1Thread extends Thread { previous = autosensData; if (bgTime < now()) autosensDataTable.put(bgTime, autosensData); - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime()); AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime); - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Sensitivity result: " + sensitivity.toString()); autosensData.autosensResult = sensitivity; - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(autosensData.toString()); } } @@ -357,7 +364,8 @@ public class IobCobOref1Thread extends Thread { } finally { mWakeLock.release(); MainApp.bus().post(new EventIobCalculationProgress("")); - log.debug("AUTOSENSDATA thread ended: " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("AUTOSENSDATA thread ended: " + from); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java index 3c072abb99..251e5f7b90 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobThread.java @@ -15,7 +15,6 @@ import java.util.Date; import java.util.List; import info.nightscout.androidaps.BuildConfig; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -24,6 +23,7 @@ import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress; import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults; @@ -42,7 +42,7 @@ import static info.nightscout.utils.DateUtil.now; */ public class IobCobThread extends Thread { - private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); + private static Logger log = LoggerFactory.getLogger(L.AUTOSENS); private final Event cause; private IobCobCalculatorPlugin iobCobCalculatorPlugin; @@ -71,13 +71,16 @@ public class IobCobThread extends Thread { public final void run() { mWakeLock.acquire(); try { - log.debug("AUTOSENSDATA thread started: " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("AUTOSENSDATA thread started: " + from); if (MainApp.getConfigBuilder() == null) { - log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Aborting calculation thread (ConfigBuilder not ready): " + from); return; // app still initializing } if (!MainApp.getConfigBuilder().isProfileValid("IobCobThread")) { - log.debug("Aborting calculation thread (No profile): " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Aborting calculation thread (No profile): " + from); return; // app still initializing } //log.debug("Locking calculateSensitivityData"); @@ -93,12 +96,14 @@ public class IobCobThread extends Thread { LongSparseArray autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); if (bucketed_data == null || bucketed_data.size() < 3) { - log.debug("Aborting calculation thread (No bucketed data available): " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Aborting calculation thread (No bucketed data available): " + from); return; } long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date); - log.debug("Prev data time: " + new Date(prevDataTime).toLocaleString()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Prev data time: " + new Date(prevDataTime).toLocaleString()); AutosensData previous = autosensDataTable.get(prevDataTime); // start from oldest to be able sub cob for (int i = bucketed_data.size() - 4; i >= 0; i--) { @@ -107,7 +112,8 @@ public class IobCobThread extends Thread { if (iobCobCalculatorPlugin.stopCalculationTrigger) { iobCobCalculatorPlugin.stopCalculationTrigger = false; - log.debug("Aborting calculation thread (trigger): " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Aborting calculation thread (trigger): " + from); return; } // check if data already exists @@ -124,11 +130,12 @@ public class IobCobThread extends Thread { Profile profile = MainApp.getConfigBuilder().getProfile(bgTime); if (profile == null) { - log.debug("Aborting calculation thread (no profile): " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("Aborting calculation thread (no profile): " + from); return; // profile not set yet } - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Processing calculation thread: " + from + " (" + i + "/" + bucketed_data.size() + ")"); double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits()); @@ -170,7 +177,7 @@ public class IobCobThread extends Thread { AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago); if (hourAgoData != null) { int initialIndex = autosensDataTable.indexOfKey(hourAgoData.time); - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(">>>>> bucketed_data.size()=" + bucketed_data.size() + " i=" + i + "hourAgoData=" + hourAgoData.toString()); int past = 1; try { @@ -186,7 +193,7 @@ public class IobCobThread extends Thread { minDeviation = ad.avgDeviation; } - //if (Config.logAutosensData) + //if (Config.isEnabled(L.AUTOSENS)) // log.debug("Deviations: " + new Date(bgTime) + new Date(ad.time) + " avgDeviation=" + avgDeviation + " deviationSlope=" + deviationSlope + " slopeFromMaxDeviation=" + slopeFromMaxDeviation + " slopeFromMinDeviation=" + slopeFromMinDeviation); } } catch (Exception e) { @@ -267,13 +274,13 @@ public class IobCobThread extends Thread { previous = autosensData; if (bgTime < now()) autosensDataTable.put(bgTime, autosensData); - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime()); AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime); - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Sensitivity result: " + sensitivity.toString()); autosensData.autosensResult = sensitivity; - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(autosensData.toString()); } } @@ -284,7 +291,8 @@ public class IobCobThread extends Thread { } finally { mWakeLock.release(); MainApp.bus().post(new EventIobCalculationProgress("")); - log.debug("AUTOSENSDATA thread ended: " + from); + if (L.isEnabled(L.AUTOSENS)) + log.debug("AUTOSENSDATA thread ended: " + from); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java index 569b9ed09c..8ea19fe8a7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java @@ -12,13 +12,13 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.utils.DecimalFormatter; @@ -26,7 +26,7 @@ import info.nightscout.utils.DecimalFormatter; * Created by mike on 09.06.2016. */ public class APSResult { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); public long date = 0; public String reason; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/DeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/DeviceStatus.java index c8d65169cd..2c2bb1a2ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/DeviceStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/DeviceStatus.java @@ -5,7 +5,7 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /* { @@ -365,7 +365,7 @@ import info.nightscout.androidaps.Constants; */ public class DeviceStatus { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); public String device = null; public JSONObject pump = null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java index 0e9a189e4e..4200317cef 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java @@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainActivity; import info.nightscout.androidaps.MainApp; @@ -38,6 +37,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui; @@ -54,7 +54,7 @@ import info.nightscout.utils.SP; * Created by mike on 05.08.2016. */ public class LoopPlugin extends PluginBase { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); private static final String CHANNEL_ID = "AndroidAPS-Openloop"; @@ -254,13 +254,13 @@ public class LoopPlugin extends PluginBase { public synchronized void invoke(String initiator, boolean allowNotification, boolean tempBasalFallback) { try { - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug("invoke from " + initiator); Constraint loopEnabled = MainApp.getConstraintChecker().isLoopInvokationAllowed(); if (!loopEnabled.value()) { String message = MainApp.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons(); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(message); MainApp.bus().post(new EventLoopSetLastRunGui(message)); return; @@ -274,7 +274,7 @@ public class LoopPlugin extends PluginBase { Profile profile = MainApp.getConfigBuilder().getProfile(); if (!MainApp.getConfigBuilder().isProfileValid("Loop")) { - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.noprofileselected)); MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.noprofileselected))); return; @@ -305,7 +305,7 @@ public class LoopPlugin extends PluginBase { // safety check for multiple SMBs long lastBolusTime = TreatmentsPlugin.getPlugin().getLastBolusTime(); if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) { - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug("SMB requsted but still in 3 min interval"); resultAfterConstraints.smb = 0; } @@ -321,14 +321,14 @@ public class LoopPlugin extends PluginBase { NSUpload.uploadDeviceStatus(); if (isSuspended()) { - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.loopsuspended)); MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.loopsuspended))); return; } if (pump.isSuspended()) { - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.pumpsuspended)); MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.pumpsuspended))); return; @@ -416,7 +416,7 @@ public class LoopPlugin extends PluginBase { MainApp.bus().post(new EventLoopUpdateGui()); } finally { - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug("invoke end"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java index f08e4e8e23..cc9d843368 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSClientPlugin.java @@ -29,6 +29,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI; @@ -37,7 +38,7 @@ import info.nightscout.utils.SP; import info.nightscout.utils.ToastUtils; public class NSClientPlugin extends PluginBase { - private Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private Logger log = LoggerFactory.getLogger(L.NSCLIENT); static NSClientPlugin nsClientPlugin; @@ -132,13 +133,13 @@ public class NSClientPlugin extends PluginBase { private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Service is disconnected"); nsClientService = null; } public void onServiceConnected(ComponentName name, IBinder service) { - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Service is connected"); NSClientService.LocalBinder mLocalBinder = (NSClientService.LocalBinder) service; if (mLocalBinder != null) // is null when running in roboelectric @@ -157,7 +158,7 @@ public class NSClientPlugin extends PluginBase { @Subscribe public void onStatusEvent(final EventNSClientNewLog ev) { addToLog(ev); - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug(ev.action + " " + ev.logText); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java index 4b9c443ecb..a3094a4646 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java @@ -21,10 +21,9 @@ import java.util.Date; import java.util.List; import java.util.Locale; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.Profile; @@ -48,7 +47,7 @@ import info.nightscout.utils.SP; */ public class NSUpload { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); public static void uploadTempBasalStartAbsolute(TemporaryBasal temporaryBasal, Double originalExtendedAmount) { try { @@ -237,7 +236,7 @@ public class NSUpload { deviceStatus.enacted.put("requested", requested); } } else { - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("OpenAPS data too old to upload"); } deviceStatus.device = "openaps://" + Build.MANUFACTURER + " " + Build.MODEL; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/UploadQueue.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/UploadQueue.java index 3b516a2ec7..9c0284029c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/UploadQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/UploadQueue.java @@ -13,18 +13,17 @@ import org.slf4j.LoggerFactory; import java.sql.SQLException; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DbRequest; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; /** * Created by mike on 21.02.2016. */ public class UploadQueue { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); public static String status() { return "QUEUE: " + MainApp.getDbHelper().size(DatabaseHelper.DATABASE_DBREQUESTS); @@ -46,7 +45,7 @@ public class UploadQueue { startService(); if (NSClientService.handler != null) { NSClientService.handler.post(() -> { - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Adding to queue: " + dbr.data); MainApp.getDbHelper().create(dbr); NSClientPlugin plugin = NSClientPlugin.getPlugin(); @@ -61,10 +60,10 @@ public class UploadQueue { startService(); if (NSClientService.handler != null) { NSClientService.handler.post(() -> { - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("ClearQueue"); MainApp.getDbHelper().deleteAllDbRequests(); - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug(status()); }); } @@ -82,7 +81,7 @@ public class UploadQueue { return; } if (MainApp.getDbHelper().deleteDbRequest(id) == 1) { - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Removed item from UploadQueue. " + UploadQueue.status()); } } catch (JSONException e) { @@ -99,7 +98,7 @@ public class UploadQueue { if (NSClientService.handler != null) { NSClientService.handler.post(() -> { MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id); - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Removing " + _id + " from UploadQueue. " + UploadQueue.status()); }); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java index d4cf775356..ed9c4c3013 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java @@ -5,10 +5,9 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.events.Event; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart; import io.socket.client.Ack; @@ -16,7 +15,7 @@ import io.socket.client.Ack; * Created by mike on 29.12.2015. */ public class NSAddAck extends Event implements Ack { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); public String _id = null; public String nsClientID = null; public JSONObject json = null; @@ -48,7 +47,7 @@ public class NSAddAck extends Event implements Ack { MainApp.bus().post(new EventNSClientRestart()); return; } - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("DBACCESS " + response.getString("result")); } return; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java index 7081318c01..42534387b2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java @@ -5,16 +5,16 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.events.Event; +import info.nightscout.androidaps.logging.L; import io.socket.client.Ack; /** * Created by mike on 21.02.2016. */ public class NSUpdateAck extends Event implements Ack { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); public boolean result = false; public String _id; public String action; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java index 48eec4f25e..da28fe9881 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java @@ -9,9 +9,9 @@ import android.support.v4.content.LocalBroadcastManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus; import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; @@ -21,7 +21,7 @@ import info.nightscout.utils.SP; * Created by mike on 24.02.2016. */ public class BroadcastStatus { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) { LocalBroadcastManager.getInstance(MainApp.instance()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java index 3c0076f46b..dc834215a9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java @@ -13,9 +13,9 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.services.Intents; import info.nightscout.utils.SP; @@ -23,7 +23,7 @@ import info.nightscout.utils.SP; * Created by mike on 20.02.2016. */ public class BroadcastTreatment { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); public static void handleNewTreatment(JSONObject treatment, boolean isDelta, boolean isLocalBypass) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java index 8ab0e783cf..ec31141002 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/DbLogger.java @@ -8,25 +8,24 @@ import org.slf4j.LoggerFactory; import java.util.List; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.utils.ToastUtils; /** * Created by mike on 02.07.2016. */ public class DbLogger { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); public static void dbAdd(Intent intent, String data) { List q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0); if (q.size() < 1) { ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.nsclientnotinstalled)); log.error("DBADD No receivers"); - } else if (Config.logNsclient) { - if (Config.logNsclient) + } else if (L.isEnabled(L.NSCLIENT)) { + if (L.isEnabled(L.NSCLIENT)) log.debug("DBADD dbAdd " + q.size() + " receivers " + data); } } @@ -36,8 +35,8 @@ public class DbLogger { if (q.size() < 1) { ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.nsclientnotinstalled)); log.error("DBREMOVE No receivers"); - } else if (Config.logNsclient) { - if (Config.logNsclient) + } else if (L.isEnabled(L.NSCLIENT)) { + if (L.isEnabled(L.NSCLIENT)) log.debug("DBREMOVE dbRemove " + q.size() + " receivers " + data); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSAlarm.java index 3506c3aa1b..7ad82220da 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSAlarm.java @@ -5,14 +5,14 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 11.06.2017. */ public class NSAlarm { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); JSONObject data; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSCal.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSCal.java index bb50d6ce75..83fe44073e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSCal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSCal.java @@ -5,10 +5,10 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class NSCal { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); public long date; public double slope; public double intercept; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java index 9d1ef6439f..1c8aea9b83 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java @@ -15,12 +15,11 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin; import info.nightscout.androidaps.plugins.Loop.APSResult; -import info.nightscout.utils.BundleLogger; +import info.nightscout.androidaps.logging.BundleLogger; import info.nightscout.utils.DateUtil; import info.nightscout.utils.Round; import info.nightscout.utils.SP; @@ -80,7 +79,7 @@ import info.nightscout.utils.SP; } */ public class NSDeviceStatus { - private Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private Logger log = LoggerFactory.getLogger(L.NSCLIENT); private static NSDeviceStatus instance = null; @@ -99,7 +98,7 @@ public class NSDeviceStatus { Bundle bundle = intent.getExtras(); if (bundle == null) return; - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Got NS devicestatus: " + BundleLogger.log(bundle)); try { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSMbg.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSMbg.java index 92ac6de937..cd4cd9cdba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSMbg.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSMbg.java @@ -5,10 +5,10 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class NSMbg { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); public long date; public double mbg; public String json; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java index 2a45b1a1a1..dc3c9f742e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java @@ -14,14 +14,14 @@ import java.util.Date; import java.util.Objects; import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; -import info.nightscout.utils.BundleLogger; +import info.nightscout.androidaps.logging.BundleLogger; /* { @@ -114,7 +114,7 @@ import info.nightscout.utils.BundleLogger; } */ public class NSSettingsStatus { - private Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private Logger log = LoggerFactory.getLogger(L.NSCLIENT); private static NSSettingsStatus instance = null; @@ -140,7 +140,7 @@ public class NSSettingsStatus { Bundle bundle = intent.getExtras(); if (bundle == null) return; - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Got NS status: " + BundleLogger.log(bundle)); if (bundle.containsKey("nsclientversioncode")) { @@ -149,7 +149,7 @@ public class NSSettingsStatus { nightscoutVersionName = bundle.getString("nightscoutversionname"); Integer nsClientVersionCode = bundle.getInt("nsclientversioncode"); String nsClientVersionName = bundle.getString("nsclientversionname"); - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Got versions: NSClient: " + nsClientVersionName + " Nightscout: " + nightscoutVersionName); try { if (nsClientVersionCode < MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode) { @@ -175,7 +175,7 @@ public class NSSettingsStatus { try { JSONObject statusJson = new JSONObject(bundle.getString("status")); setData(statusJson); - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Received status: " + statusJson.toString()); Double targetHigh = getThreshold("bgTargetTop"); Double targetlow = getThreshold("bgTargetBottom"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSgv.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSgv.java index c9b8605e9e..2212884a3e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSgv.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSgv.java @@ -5,14 +5,14 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * * {"mgdl":105,"mills":1455136282375,"device":"xDrip-BluetoothWixel","direction":"Flat","filtered":98272,"unfiltered":98272,"noise":1,"rssi":100} */ public class NSSgv { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); private JSONObject data; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSTreatment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSTreatment.java index a494024928..d4ee20e2a1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSTreatment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSTreatment.java @@ -7,10 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class NSTreatment { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); private JSONObject data; private String action = null; // "update", "remove" or null (add) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/AckAlarmReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/AckAlarmReceiver.java index 6145a57b50..f23533e9ab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/AckAlarmReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/AckAlarmReceiver.java @@ -9,19 +9,17 @@ import android.os.PowerManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.data.AlarmAck; import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; import info.nightscout.utils.SP; public class AckAlarmReceiver extends BroadcastReceiver { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); @Override @@ -34,7 +32,7 @@ public class AckAlarmReceiver extends BroadcastReceiver { return; } if (SP.getBoolean(R.string.key_ns_noupload, false)) { - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Upload disabled. Message dropped"); return; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java index 996e62b306..a1300f7b99 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/receivers/DBAccessReceiver.java @@ -11,11 +11,11 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.db.DbRequest; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue; import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastTreatment; @@ -23,7 +23,7 @@ import info.nightscout.utils.DateUtil; import info.nightscout.utils.SP; public class DBAccessReceiver extends BroadcastReceiver { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java index 536a9fe819..d7066705b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java @@ -24,7 +24,6 @@ import java.net.URISyntaxException; import java.sql.SQLException; import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.ProfileStore; @@ -33,6 +32,7 @@ import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventConfigBuilderChange; import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue; import info.nightscout.androidaps.plugins.NSClientInternal.acks.NSAddAck; @@ -69,7 +69,7 @@ import io.socket.client.Socket; import io.socket.emitter.Emitter; public class NSClientService extends Service { - private static Logger log = LoggerFactory.getLogger(Constants.NSCLIENT); + private static Logger log = LoggerFactory.getLogger(L.NSCLIENT); static public PowerManager.WakeLock mWakeLock; private IBinder mBinder = new NSClientService.LocalBinder(); @@ -155,13 +155,13 @@ public class NSClientService extends Service { @Subscribe public void onStatusEvent(EventAppExit event) { - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("EventAppExit received"); destroy(); stopSelf(); - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("EventAppExit finished"); } @@ -249,7 +249,7 @@ public class NSClientService extends Service { private Emitter.Listener onDisconnect = new Emitter.Listener() { @Override public void call(Object... args) { - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("disconnect reason: {}", args); MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "disconnect event")); } @@ -361,7 +361,7 @@ public class NSClientService extends Service { log.error("Unhandled exception", e); } BroadcastAnnouncement.handleAnnouncement(data, getApplicationContext()); - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug(data.toString()); } }; @@ -392,7 +392,7 @@ public class NSClientService extends Service { return; } BroadcastAlarm.handleAlarm(data, getApplicationContext()); - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug(data.toString()); } }; @@ -423,7 +423,7 @@ public class NSClientService extends Service { } MainApp.bus().post(new EventNSClientNewLog("URGENTALARM", "received")); BroadcastUrgentAlarm.handleUrgentAlarm(data, getApplicationContext()); - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug(data.toString()); } }; @@ -449,7 +449,7 @@ public class NSClientService extends Service { } MainApp.bus().post(new EventNSClientNewLog("CLEARALARM", "received")); BroadcastClearAlarm.handleClearAlarm(data, getApplicationContext()); - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug(data.toString()); } }; @@ -759,7 +759,7 @@ public class NSClientService extends Service { if (mSocket == null || !mSocket.connected()) return; if (lastResendTime > System.currentTimeMillis() - 10 * 1000L) { - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Skipping resend by lastResendTime: " + ((System.currentTimeMillis() - lastResendTime) / 1000L) + " sec"); return; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java index d178c8a5a5..50e79d1e37 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java @@ -17,7 +17,6 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -26,6 +25,7 @@ import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback; @@ -34,7 +34,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.utils.SP; public class DetermineBasalAdapterAMAJS { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); private ScriptReader mScriptReader = null; @@ -61,7 +61,7 @@ public class DetermineBasalAdapterAMAJS { public DetermineBasalResultAMA invoke() { - if (Config.logAps) { + if (L.isEnabled(L.APS)) { log.debug(">>> Invoking detemine_basal <<<"); log.debug("Glucose status: " + (storedGlucoseStatus = mGlucoseStatus.toString())); log.debug("IOB data: " + (storedIobData = mIobData.toString())); @@ -119,7 +119,7 @@ public class DetermineBasalAdapterAMAJS { // Parse the jsResult object to a JSON-String String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString(); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug("Result: " + result); try { determineBasalResultAMA = new DetermineBasalResultAMA(jsResult, new JSONObject(result)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java index 324336f0d2..7d57f52efb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java @@ -6,12 +6,12 @@ import org.mozilla.javascript.NativeObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.utils.DateUtil; public class DetermineBasalResultAMA extends APSResult { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); private double eventualBG; private double snoozeBG; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java index 6e22ac028b..0eb327c608 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAFragment.java @@ -16,9 +16,9 @@ import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui; @@ -26,7 +26,7 @@ import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.JSONFormatter; public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); Button run; TextView lastRunView; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index 905b595331..1c6bf3e39d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -6,8 +6,6 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.GlucoseStatus; @@ -21,6 +19,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; @@ -39,7 +38,7 @@ import info.nightscout.utils.Round; * Created by mike on 05.08.2016. */ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); private static OpenAPSAMAPlugin openAPSAMAPlugin; @@ -91,7 +90,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { @Override public void invoke(String initiator, boolean tempBasalFallback) { - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback); lastAPSResult = null; DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS; @@ -103,21 +102,21 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { if (profile == null) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.noprofileselected)); return; } if (!isEnabled(PluginType.APS)) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled))); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.openapsma_disabled)); return; } if (glucoseStatus == null) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata))); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.openapsma_noglucosedata)); return; } @@ -135,12 +134,12 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { Date start = new Date(); Date startPart = new Date(); IobTotal[] iobArray = IobCobCalculatorPlugin.getPlugin().calculateIobArrayInDia(profile); - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "calculateIobArrayInDia()", startPart); startPart = new Date(); MealData mealData = TreatmentsPlugin.getPlugin().getMealData(); - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "getMealData()", startPart); double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value(); @@ -182,9 +181,9 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { lastAutosensResult = new AutosensResult(); lastAutosensResult.sensResult = "autosens disabled"; } - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart); - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "AMA data gathering", start); start = new Date(); @@ -200,7 +199,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { DetermineBasalResultAMA determineBasalResultAMA = determineBasalAdapterAMAJS.invoke(); - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "AMA calculation", start); // Fix bug determine basal if (determineBasalResultAMA.rate == 0d && determineBasalResultAMA.duration == 0 && !TreatmentsPlugin.getPlugin().isTempBasalInProgress()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java index 0dd8d6e288..1574665dc4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java @@ -15,7 +15,6 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.GlucoseStatus; @@ -23,12 +22,13 @@ import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.utils.SP; public class DetermineBasalAdapterMAJS { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); private ScriptReader mScriptReader; private JSONObject mProfile; @@ -96,7 +96,7 @@ public class DetermineBasalAdapterMAJS { // Parse the jsResult object to a JSON-String String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString(); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug("Result: " + result); try { determineBasalResultMA = new DetermineBasalResultMA(jsResult, new JSONObject(result)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java index 006b4343e3..3f0e9abea9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java @@ -6,11 +6,11 @@ import org.mozilla.javascript.NativeObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Loop.APSResult; public class DetermineBasalResultMA extends APSResult { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); public JSONObject json = new JSONObject(); private double eventualBG; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/LoggerCallback.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/LoggerCallback.java index 8f7fd181e0..8907166951 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/LoggerCallback.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/LoggerCallback.java @@ -4,8 +4,7 @@ import org.mozilla.javascript.ScriptableObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by adrian on 15/10/17. @@ -14,7 +13,7 @@ import info.nightscout.androidaps.Constants; public class LoggerCallback extends ScriptableObject { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); private static StringBuffer errorBuffer = new StringBuffer(); private static StringBuffer logBuffer = new StringBuffer(); @@ -36,14 +35,14 @@ public class LoggerCallback extends ScriptableObject { } public void jsFunction_log(Object obj1) { - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(obj1.toString()); logBuffer.append(obj1.toString()); logBuffer.append(' '); } public void jsFunction_error(Object obj1) { - if (Config.logAps) + if (L.isEnabled(L.APS)) log.error(obj1.toString()); errorBuffer.append(obj1.toString()); errorBuffer.append(' '); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java index a7a96e3bf4..ce350011cd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java @@ -6,8 +6,6 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.GlucoseStatus; @@ -21,6 +19,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.ScriptReader; @@ -39,7 +38,7 @@ import static info.nightscout.utils.HardLimits.verifyHardLimits; * Created by mike on 05.08.2016. */ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); private static OpenAPSMAPlugin openAPSMAPlugin; @@ -90,7 +89,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { @Override public void invoke(String initiator, boolean tempBasalFallback) { - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback); lastAPSResult = null; DetermineBasalAdapterMAJS determineBasalAdapterMAJS = null; @@ -102,21 +101,21 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { if (profile == null) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.noprofileselected)); return; } if (!isEnabled(PluginType.APS)) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled))); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.openapsma_disabled)); return; } if (glucoseStatus == null) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata))); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.openapsma_noglucosedata)); return; } @@ -143,7 +142,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { MealData mealData = TreatmentsPlugin.getPlugin().getMealData(); double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value(); - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "MA data gathering", start); minBg = verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]); @@ -174,7 +173,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { } catch (JSONException e) { log.error("Unhandled exception", e); } - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "MA calculation", start); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java index 4fc3604bef..7ede714c10 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java @@ -17,7 +17,6 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -26,6 +25,7 @@ import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback; @@ -34,7 +34,7 @@ import info.nightscout.utils.SP; import info.nightscout.utils.SafeParse; public class DetermineBasalAdapterSMBJS { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); private ScriptReader mScriptReader; @@ -71,7 +71,7 @@ public class DetermineBasalAdapterSMBJS { public DetermineBasalResultSMB invoke() { - if (Config.logAps) { + if (L.isEnabled(L.APS)) { log.debug(">>> Invoking detemine_basal <<<"); log.debug("Glucose status: " + (storedGlucoseStatus = mGlucoseStatus.toString())); log.debug("IOB data: " + (storedIobData = mIobData.toString())); @@ -136,7 +136,7 @@ public class DetermineBasalAdapterSMBJS { // Parse the jsResult object to a JSON-String String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString(); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug("Result: " + result); try { determineBasalResultSMB = new DetermineBasalResultSMB(new JSONObject(result)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java index a4241e29d7..bd41120e30 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java @@ -5,12 +5,12 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.utils.DateUtil; public class DetermineBasalResultSMB extends APSResult { - private static final Logger log = LoggerFactory.getLogger(Constants.APS); + private static final Logger log = LoggerFactory.getLogger(L.APS); private double eventualBG; private double snoozeBG; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java index 58138e974a..91b488e742 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java @@ -19,9 +19,9 @@ import org.slf4j.LoggerFactory; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui; @@ -29,7 +29,7 @@ import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.JSONFormatter; public class OpenAPSSMBFragment extends SubscriberFragment { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); @BindView(R.id.openapsma_run) Button run; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java index b3788cf1f2..64daaed9c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java @@ -6,8 +6,6 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.GlucoseStatus; @@ -22,6 +20,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; @@ -42,7 +41,7 @@ import info.nightscout.utils.ToastUtils; * Created by mike on 05.08.2016. */ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { - private static Logger log = LoggerFactory.getLogger(Constants.APS); + private static Logger log = LoggerFactory.getLogger(L.APS); private static OpenAPSSMBPlugin openAPSSMBPlugin; @@ -94,7 +93,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { @Override public void invoke(String initiator, boolean tempBasalFallback) { - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug("invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback); lastAPSResult = null; DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS; @@ -106,21 +105,21 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { if (profile == null) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.noprofileselected)); return; } if (!isEnabled(PluginType.APS)) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled))); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.openapsma_disabled)); return; } if (glucoseStatus == null) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata))); - if (Config.logAps) + if (L.isEnabled(L.APS)) log.debug(MainApp.gs(R.string.openapsma_noglucosedata)); return; } @@ -142,12 +141,12 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { Date start = new Date(); Date startPart = new Date(); IobTotal[] iobArray = IobCobCalculatorPlugin.getPlugin().calculateIobArrayForSMB(profile); - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "calculateIobArrayInDia()", startPart); startPart = new Date(); MealData mealData = TreatmentsPlugin.getPlugin().getMealData(); - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "getMealData()", startPart); double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value(); @@ -198,9 +197,9 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { MainApp.getConstraintChecker().isAdvancedFilteringEnabled(advancedFiltering); inputConstraints.copyReasons(advancedFiltering); - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "detectSensitivityandCarbAbsorption()", startPart); - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "SMB data gathering", start); start = new Date(); @@ -219,7 +218,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { long now = System.currentTimeMillis(); DetermineBasalResultSMB determineBasalResultSMB = determineBasalAdapterSMBJS.invoke(); - if (Config.logAps) + if (L.isEnabled(L.APS)) Profiler.log(log, "SMB calculation", start); // TODO still needed with oref1? // Fix bug determine basal diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index b0655d894e..91dbb29042 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -80,6 +80,7 @@ import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; @@ -125,7 +126,7 @@ import info.nightscout.utils.ToastUtils; import static info.nightscout.utils.DateUtil.now; public class OverviewFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener { - private static Logger log = LoggerFactory.getLogger(Constants.OVERVIEW); + private static Logger log = LoggerFactory.getLogger(L.OVERVIEW); TextView timeView; TextView bgView; @@ -825,7 +826,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> { synchronized (builder) { if (accepted) { - if (Config.logOverview) + if (L.isEnabled(L.OVERVIEW)) log.debug("guarding: already accepted"); return; } @@ -1031,7 +1032,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, @SuppressLint("SetTextI18n") public void updateGUI(final String from) { - if (Config.logOverview) + if (L.isEnabled(L.OVERVIEW)) log.debug("updateGUI entered from: " + from); final Date updateGUIStart = new Date(); @@ -1427,7 +1428,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, final long now = System.currentTimeMillis(); // ------------------ 1st graph - if (Config.logOverview) + if (L.isEnabled(L.OVERVIEW)) Profiler.log(log, from + " - 1st graph - START", updateGUIStart); final GraphData graphData = new GraphData(bgGraph, IobCobCalculatorPlugin.getPlugin()); @@ -1460,7 +1461,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, graphData.addNowLine(now); // ------------------ 2nd graph - if (Config.logOverview) + if (L.isEnabled(L.OVERVIEW)) Profiler.log(log, from + " - 2nd graph - START", updateGUIStart); final GraphData secondGraphData = new GraphData(iobGraph, IobCobCalculatorPlugin.getPlugin()); @@ -1515,13 +1516,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, // finally enforce drawing of graphs graphData.performUpdate(); secondGraphData.performUpdate(); - if (Config.logOverview) + if (L.isEnabled(L.OVERVIEW)) Profiler.log(log, from + " - onDataChanged", updateGUIStart); }); } }).start(); - if (Config.logOverview) + if (L.isEnabled(L.OVERVIEW)) Profiler.log(log, from, updateGUIStart); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java index eea249c2e2..dfd6b9970c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewPlugin.java @@ -7,7 +7,6 @@ import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; @@ -16,6 +15,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore; @@ -25,7 +25,7 @@ import info.nightscout.utils.SP; * Created by mike on 05.08.2016. */ public class OverviewPlugin extends PluginBase { - private static Logger log = LoggerFactory.getLogger(Constants.OVERVIEW); + private static Logger log = LoggerFactory.getLogger(L.OVERVIEW); private static OverviewPlugin overviewPlugin = new OverviewPlugin(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java index d750965d38..72fbbff5a5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -28,6 +27,7 @@ import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.TempTarget; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.BasalData; @@ -51,7 +51,7 @@ import info.nightscout.utils.Round; */ public class GraphData { - private static Logger log = LoggerFactory.getLogger(Constants.OVERVIEW); + private static Logger log = LoggerFactory.getLogger(L.OVERVIEW); private GraphView graph; public double maxY = Double.MIN_VALUE; @@ -75,7 +75,7 @@ public class GraphData { List bgListArray = new ArrayList<>(); if (bgReadingsArray == null || bgReadingsArray.size() == 0) { - if (Config.logOverview) + if (L.isEnabled(L.OVERVIEW)) log.debug("No BG data."); return; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java index 02390154b6..9af6be3be3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java @@ -15,10 +15,9 @@ import org.slf4j.LoggerFactory; import java.util.List; import java.util.Objects; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastAckAlarm; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; @@ -26,7 +25,7 @@ import info.nightscout.utils.DateUtil; import info.nightscout.utils.SP; public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter { - private static Logger log = LoggerFactory.getLogger(Constants.NOTIFICATION); + private static Logger log = LoggerFactory.getLogger(L.NOTIFICATION); private List notificationsList; @@ -98,12 +97,12 @@ public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter store = new ArrayList<>(); private boolean usesChannels; @@ -52,7 +52,7 @@ public class NotificationStore { } public synchronized boolean add(Notification n) { - if (Config.logNotification) + if (L.isEnabled(L.NOTIFICATION)) log.debug("Notification received: " + n.text); for (Notification storeNotification : store) { if (storeNotification.id == n.id) { @@ -108,7 +108,7 @@ public class NotificationStore { } public void snoozeTo(long timeToSnooze) { - if (Config.logNotification) + if (L.isEnabled(L.NOTIFICATION)) log.debug("Snoozing alarm until: " + timeToSnooze); SP.putLong("snoozedTo", timeToSnooze); } @@ -118,7 +118,7 @@ public class NotificationStore { Notification notification = new Notification(Notification.NSALARM, MainApp.gs(R.string.nsalarm_staledata), Notification.URGENT); SP.putLong("snoozedTo", System.currentTimeMillis()); add(notification); - if (Config.logNotification) + if (L.isEnabled(L.NOTIFICATION)) log.debug("Snoozed to current time and added back notification!"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java index e86772fc36..522964e557 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/NSProfilePlugin.java @@ -13,6 +13,7 @@ import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.events.EventProfileStoreChanged; @@ -77,7 +78,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface { MainApp.bus().post(new EventProfileStoreChanged()); MainApp.bus().post(new EventNSProfileUpdateGUI()); } - if (Config.logNsclient) + if (L.isEnabled(L.NSCLIENT)) log.debug("Received profileStore: " + activeProfile + " " + profile); } catch (JSONException e) { log.error("Unhandled exception", e); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index 7361f15850..7116056657 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -22,8 +22,6 @@ import java.util.HashSet; import java.util.List; import info.nightscout.androidaps.BuildConfig; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -42,6 +40,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; @@ -71,7 +70,7 @@ import info.nightscout.utils.SP; * Created by mike on 05.08.2016. */ public class ComboPlugin extends PluginBase implements PumpInterface, ConstraintsInterface { - private static final Logger log = LoggerFactory.getLogger(Constants.PUMP); + private static final Logger log = LoggerFactory.getLogger(L.PUMP); static final String COMBO_TBRS_SET = "combo_tbrs_set"; static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered"; @@ -209,14 +208,14 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint public void onClick(DialogInterface dialog, int id) { pluginSwitcher.invoke(); SP.putBoolean("allow_hardware_pump", true); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("First time HW pump allowed!"); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.cancel(); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("User does not allow switching to HW pump!"); } }); @@ -264,7 +263,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint @Override public void disconnect(String reason) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Disconnect called with reason: " + reason); ruffyScripter.disconnect(); } @@ -364,7 +363,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint */ @Override public synchronized void getPumpStatus() { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("getPumpStatus called"); if (!pump.initialized) { initializePump(); @@ -377,11 +376,11 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint private synchronized void initializePump() { long maxWait = System.currentTimeMillis() + 15 * 1000; while (!ruffyScripter.isPumpAvailable()) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Waiting for ruffy service to come up ..."); SystemClock.sleep(100); if (System.currentTimeMillis() > maxWait) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("ruffy service unavailable, wtf"); return; } @@ -401,7 +400,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // note that since the history is checked upon every connect, the above already updated // the DB with any changed history records if (pumpHistoryChanged) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Pump history has changed and was imported"); pumpHistoryChanged = false; } @@ -551,7 +550,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // within the last 1-2 minutes if (Math.abs(previousBolus.amount - detailedBolusInfo.insulin) < 0.01 && previousBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Bolus request rejected, same bolus was successfully delivered very recently"); return new PumpEnactResult().success(false).enacted(false) .comment(MainApp.gs(R.string.bolus_frequency_exceeded)); @@ -572,7 +571,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint return new PumpEnactResult().success(false).enacted(false) .comment(MainApp.gs(R.string.combo_error_no_connection_no_bolus_delivered)); } - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Waiting for pump clock to advance for the next unused bolus record timestamp"); SystemClock.sleep(2000); timeCheckResult = runCommand(null, 0, ruffyScripter::readPumpState); @@ -584,7 +583,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("waitTimeSecs", String.valueOf(waitDuration))); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing"); } @@ -747,12 +746,12 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint */ @Override public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean force) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute called with a rate of " + absoluteRate + " for " + durationInMinutes + " min."); int unroundedPercentage = Double.valueOf(absoluteRate / getBaseBasalRate() * 100).intValue(); int roundedPercentage = (int) (Math.round(absoluteRate / getBaseBasalRate() * 10) * 10); if (unroundedPercentage != roundedPercentage) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Rounded requested rate " + unroundedPercentage + "% -> " + roundedPercentage + "%"); } @@ -771,7 +770,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint } private PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalPercent called with " + percent + "% for " + durationInMinutes + "min"); if (pumpHistoryChanged && percent > 110) { @@ -782,14 +781,14 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint int adjustedPercent = percent; if (adjustedPercent > pumpDescription.maxTempPercent) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Reducing requested TBR to the maximum support by the pump: " + percent + " -> " + pumpDescription.maxTempPercent); adjustedPercent = pumpDescription.maxTempPercent; } if (adjustedPercent % 10 != 0) { Long rounded = Math.round(adjustedPercent / 10d) * 10; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Rounded requested percentage:" + adjustedPercent + " -> " + rounded); adjustedPercent = rounded.intValue(); } @@ -839,7 +838,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint */ @Override public PumpEnactResult cancelTempBasal(boolean enforceNew) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("cancelTempBasal called"); final TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()); if (enforceNew) { @@ -850,7 +849,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint if (!stateResult.state.tbrActive) { return new PumpEnactResult().success(true).enacted(false); } - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("cancelTempBasal: hard-cancelling TBR since force requested"); CommandResult cancelResult = runCommand(MainApp.gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr); if (!cancelResult.success) { @@ -872,7 +871,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // Let fake neutral temp keep run (see below) // Note that since this runs on the queue a connection is opened regardless, but this // case doesn't occur all that often, so it's not worth optimizing (1.3k SetTBR vs 4 cancelTBR). - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("cancelTempBasal: skipping changing tbr since it already is at " + activeTemp.percentRate + "% and running for another " + activeTemp.getPlannedRemainingMinutes() + " mins."); return new PumpEnactResult().success(true).enacted(true) .comment("cancelTempBasal skipping changing tbr since it already is at " @@ -882,7 +881,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // Set a fake neutral temp to avoid TBR cancel alert. Decide 90% vs 110% based on // on whether the TBR we're cancelling is above or below 100%. final int percentage = (activeTemp.percentRate > 100) ? 110 : 90; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("cancelTempBasal: changing TBR to " + percentage + "% for 15 mins."); return setTempBasalPercent(percentage, 15); } @@ -922,7 +921,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint if (!commandResult.success && retries > 0) { for (int retryAttempts = 1; !commandResult.success && retryAttempts <= retries; retryAttempts++) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Command was not successful, retries requested, doing retry #" + retryAttempts); commandResult = commandExecution.execute(); } @@ -1004,7 +1003,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint long now = System.currentTimeMillis(); TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now); if (aapsTbr == null || aapsTbr.percentRate != 0) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Creating 15m zero temp since pump is suspended"); TemporaryBasal newTempBasal = new TemporaryBasal() .date(now) @@ -1065,12 +1064,12 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint if (state.pumpTime == 0) { // time couldn't be read (e.g. a warning is displayed on the menu , hiding the time field) } else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 10 * 60 * 1000) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")"); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_notification_check_time_date), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); } else if (Math.abs(state.pumpTime - System.currentTimeMillis()) >= 3 * 60 * 1000) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Pump clock needs update, pump time: " + state.pumpTime + " (" + new Date(state.pumpTime) + ")"); Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_notification_check_time_date), Notification.NORMAL); MainApp.bus().post(new EventNewNotification(notification)); @@ -1133,7 +1132,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint long now = System.currentTimeMillis(); TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now); if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Creating temp basal from pump TBR"); FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) @@ -1146,7 +1145,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint .source(Source.USER); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(newTempBasal); } else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Ending AAPS-TBR since pump has no TBR active"); FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch") .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) @@ -1160,7 +1159,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint } else if (aapsTbr != null && state.tbrActive && (aapsTbr.percentRate != state.tbrPercent || Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) 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) @@ -1246,7 +1245,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // no history, nothing to check or complain about if (quickInfoResult.history == null || quickInfoResult.history.bolusHistory.isEmpty()) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Setting 'pumpHistoryChanged' false"); pumpHistoryChanged = false; return null; @@ -1256,14 +1255,14 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint List initialPumpBolusHistory = quickInfoResult.history.bolusHistory; if (recentBoluses.size() == 1 && initialPumpBolusHistory.size() >= 1 && recentBoluses.get(0).equals(quickInfoResult.history.bolusHistory.get(0))) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Setting 'pumpHistoryChanged' false"); pumpHistoryChanged = false; return null; } else if (recentBoluses.size() == 2 && initialPumpBolusHistory.size() >= 2 && recentBoluses.get(0).equals(quickInfoResult.history.bolusHistory.get(0)) && recentBoluses.get(1).equals(quickInfoResult.history.bolusHistory.get(1))) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Setting 'pumpHistoryChanged' false"); pumpHistoryChanged = false; return null; @@ -1284,7 +1283,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint // for. HashSet bolusSet = new HashSet<>(historyResult.history.bolusHistory); if (bolusSet.size() != historyResult.history.bolusHistory.size()) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) 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) @@ -1298,7 +1297,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history); if (pumpHistoryChanged) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Setting 'pumpHistoryChanged' true"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java index 434630d14a..81f301b81b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/AbstractDanaRPlugin.java @@ -10,8 +10,6 @@ import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.BuildConfig; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; @@ -28,6 +26,7 @@ import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; @@ -45,7 +44,7 @@ import info.nightscout.utils.SP; */ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface { - protected Logger log = LoggerFactory.getLogger(Constants.PUMP); + protected Logger log = LoggerFactory.getLogger(L.PUMP); protected AbstractDanaRExecutionService sExecutionService; @@ -135,7 +134,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement); if (profileValue == null) return true; if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); return false; } @@ -186,7 +185,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalPercent: Correct value already set"); return result; } @@ -200,7 +199,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalPercent: OK"); return result; } @@ -228,7 +227,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte result.absolute = pump.extendedBolusAbsoluteRate; result.isPercent = false; result.isTempCancel = false; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin); return result; } @@ -243,7 +242,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte if (!SP.getBoolean("danar_useextended", false)) result.bolusDelivered = pump.extendedBolusAmount; result.isPercent = false; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setExtendedBolus: OK"); return result; } @@ -266,7 +265,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte if (!pump.isExtendedInProgress) { result.success = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("cancelExtendedBolus: OK"); return result; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java index db1b10ddbe..f261bc470d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java @@ -23,8 +23,6 @@ import org.slf4j.LoggerFactory; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.activities.TDDStatsActivity; @@ -33,6 +31,7 @@ import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog; @@ -47,7 +46,7 @@ import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.SetWarnColor; public class DanaRFragment extends SubscriberFragment { - private static Logger log = LoggerFactory.getLogger(Constants.PUMP); + private static Logger log = LoggerFactory.getLogger(L.PUMP); private Handler loopHandler = new Handler(); private Runnable refreshLoop = new Runnable() { @@ -146,7 +145,7 @@ public class DanaRFragment extends SubscriberFragment { @OnClick(R.id.danar_btconnection) void onBtConnectionClick() { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Clicked connect to pump"); DanaRPump.getInstance().lastConnection = 0; ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java index b600417a3a..68ea3fe851 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java @@ -11,9 +11,6 @@ import android.support.v7.app.AlertDialog; import com.squareup.otto.Subscribe; -import org.slf4j.LoggerFactory; - -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -21,6 +18,7 @@ import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed; import info.nightscout.androidaps.plugins.Treatments.Treatment; @@ -93,14 +91,14 @@ public class DanaRPlugin extends AbstractDanaRPlugin { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.invoke(); SP.putBoolean("allow_hardware_pump", true); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("First time HW pump allowed!"); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.cancel(); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("User does not allow switching to HW pump!"); } }); @@ -128,13 +126,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin { private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Service is disconnected"); sExecutionService = null; } public void onServiceConnected(ComponentName name, IBinder service) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Service is connected"); DanaRExecutionService.LocalBinder mLocalBinder = (DanaRExecutionService.LocalBinder) service; sExecutionService = mLocalBinder.getServiceInstance(); @@ -198,7 +196,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode); else result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.date = System.currentTimeMillis(); @@ -240,13 +238,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin { if (doTempOff) { // If extended in progress if (activeExtended != null && useExtendedBoluses) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)"); return cancelExtendedBolus(); } // If temp in progress if (activeTemp != null) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); return cancelRealTempBasal(); } @@ -255,7 +253,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.percent = 100; result.isPercent = true; result.isTempCancel = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: doTempOff OK"); return result; } @@ -267,12 +265,12 @@ public class DanaRPlugin extends AbstractDanaRPlugin { if (percentRate > getPumpDescription().maxTempPercent) { percentRate = getPumpDescription().maxTempPercent; } - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate); // If extended in progress if (activeExtended != null && useExtendedBoluses) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)"); result = cancelExtendedBolus(); if (!result.success) { @@ -283,7 +281,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { // Check if some temp is already in progress if (activeTemp != null) { // Correct basal already set ? - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString()); if (activeTemp.percentRate == percentRate) { if (enforceNew) { @@ -295,21 +293,21 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.duration = activeTemp.getPlannedRemainingMinutes(); result.isPercent = true; result.isTempCancel = false; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); return result; } } } // Convert duration from minutes to hours - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); return setTempBasalPercent(percentRate, durationInMinutes, profile, false); } if (doExtendedTemp) { // Check if some temp is already in progress if (activeTemp != null) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)"); result = cancelRealTempBasal(); // Check for proper result @@ -328,7 +326,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours // What is current rate of extended bolusing in u/h? - if (Config.logPump) { + if (L.isEnabled(L.PUMP)) { log.debug("setTempBasalAbsolute: Extended bolus in progress: " + (activeExtended != null) + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min"); log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h"); } @@ -342,21 +340,21 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.duration = pump.extendedBolusRemainingMinutes; result.isPercent = false; result.isTempCancel = false; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Correct extended already set"); return result; } // Now set new extended, no need to to stop previous (if running) because it's replaced Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours); result = setExtendedBolus(extendedAmount, durationInMinutes); if (!result.success) { log.error("setTempBasalAbsolute: Failed to set extended bolus"); return result; } - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Extended bolus set ok"); result.absolute = result.absolute + getBaseBasalRate(); return result; @@ -395,7 +393,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { result.success = true; result.isTempCancel = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("cancelRealTempBasal: OK"); return result; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java index f5c7f7f652..b5c1e6030e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java @@ -9,18 +9,18 @@ import org.slf4j.LoggerFactory; import java.text.DecimalFormat; import java.util.Date; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.ProfileStore; +import info.nightscout.androidaps.logging.L; import info.nightscout.utils.SP; /** * Created by mike on 04.07.2016. */ public class DanaRPump { - private Logger log = LoggerFactory.getLogger(Constants.PUMP); + private Logger log = LoggerFactory.getLogger(L.PUMP); private static DanaRPump instance = null; @@ -242,7 +242,7 @@ public class DanaRPump { //Some values get truncated to the next lower one. // -> round them to two decimals and make sure we are a small delta larger (that will get truncated) double value = Math.round(100d * nsProfile.getBasalTimeFromMidnight((Integer) (hour * 60 * 60)))/100d + 0.00001; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("NS basal value for " + hour + ":00 is " + value); record[hour] = value; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java index 295393cc1a..a319353d63 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java @@ -10,8 +10,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageHashTable; import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread; @@ -21,7 +20,7 @@ import info.nightscout.utils.CRC; * Created by mike on 17.07.2016. */ public class SerialIOThread extends AbstractSerialIOThread { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPBTCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPBTCOMM); private InputStream mInputStream = null; private OutputStream mOutputStream = null; @@ -72,7 +71,7 @@ public class SerialIOThread extends AbstractSerialIOThread { message = MessageHashTable.findMessage(command); } - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff)); // process the message content @@ -148,7 +147,7 @@ public class SerialIOThread extends AbstractSerialIOThread { processedMessage = message; byte[] messageBytes = message.getRawMessageBytes(); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes)); try { @@ -170,7 +169,7 @@ public class SerialIOThread extends AbstractSerialIOThread { log.warn("Reply not received " + message.getMessageName()); if (message.getCommand() == 0xF0F1) { DanaRPump.getInstance().isNewPump = false; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Old firmware detected"); } } @@ -182,28 +181,28 @@ public class SerialIOThread extends AbstractSerialIOThread { try { mInputStream.close(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } try { mOutputStream.close(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } try { mRfCommSocket.close(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } try { System.runFinalization(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("Disconnected: " + reason); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java index 154c08ee95..444a11b5c4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRHistoryActivity.java @@ -24,7 +24,6 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -32,6 +31,7 @@ import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.DanaRHistoryRecord; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; @@ -43,7 +43,7 @@ import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.ToastUtils; public class DanaRHistoryActivity extends Activity { - private static Logger log = LoggerFactory.getLogger(Constants.PUMP); + private static Logger log = LoggerFactory.getLogger(L.PUMP); private Handler mHandler; @@ -349,7 +349,7 @@ public class DanaRHistoryActivity extends Activity { @Subscribe public void onStatusEvent(final EventDanaRSyncStatus s) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("EventDanaRSyncStatus: " + s.message); runOnUiThread( () -> statusView.setText(s.message)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java index 0697389c48..36bad4f6fa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRNSHistorySync.java @@ -8,13 +8,12 @@ import org.slf4j.LoggerFactory; import java.util.Calendar; import java.util.List; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.DanaRHistoryRecord; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; import info.nightscout.utils.DateUtil; @@ -25,7 +24,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; */ public class DanaRNSHistorySync { - private static Logger log = LoggerFactory.getLogger(Constants.PUMP); + private static Logger log = LoggerFactory.getLogger(L.PUMP); private List historyRecords; public final static int SYNC_BOLUS = 0b00000001; @@ -50,7 +49,7 @@ public class DanaRNSHistorySync { long records = historyRecords.size(); long processing = 0; long uploaded = 0; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Database contains " + records + " records"); EventDanaRSyncStatus ev = new EventDanaRSyncStatus(); for (DanaRHistoryRecord record : historyRecords) { @@ -64,7 +63,7 @@ public class DanaRNSHistorySync { if ((what & SYNC_BOLUS) == 0) break; switch (record.bolusType) { case "S": - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Syncing standard bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "Meal Bolus"); @@ -77,7 +76,7 @@ public class DanaRNSHistorySync { break; case "E": if (record.recordDuration > 0) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", CareportalEvent.COMBOBOLUS); @@ -94,12 +93,12 @@ public class DanaRNSHistorySync { uploaded++; ev.message += MainApp.gs(R.string.danar_ebolus); } else { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("NOT Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate) + " zero duration"); } break; case "DS": - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Syncing dual(S) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", CareportalEvent.COMBOBOLUS); @@ -113,7 +112,7 @@ public class DanaRNSHistorySync { ev.message += MainApp.gs(R.string.danar_dsbolus); break; case "DE": - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Syncing dual(E) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", CareportalEvent.COMBOBOLUS); @@ -136,7 +135,7 @@ public class DanaRNSHistorySync { break; case RecordTypes.RECORD_TYPE_ERROR: if ((what & SYNC_ERROR) == 0) break; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Syncing error record " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "Note"); @@ -149,7 +148,7 @@ public class DanaRNSHistorySync { break; case RecordTypes.RECORD_TYPE_REFILL: if ((what & SYNC_REFILL) == 0) break; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Syncing refill record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "Insulin Change"); @@ -162,7 +161,7 @@ public class DanaRNSHistorySync { break; case RecordTypes.RECORD_TYPE_BASALHOUR: if ((what & SYNC_BASALHOURS) == 0) break; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Syncing basal hour record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", CareportalEvent.TEMPBASAL); @@ -179,7 +178,7 @@ public class DanaRNSHistorySync { break; case RecordTypes.RECORD_TYPE_GLUCOSE: if ((what & SYNC_GLUCOSE) == 0) break; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Syncing glucose record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "BG Check"); @@ -193,7 +192,7 @@ public class DanaRNSHistorySync { break; case RecordTypes.RECORD_TYPE_CARBO: if ((what & SYNC_CARBO) == 0) break; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Syncing carbo record " + record.recordValue + "g " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "Meal Bolus"); @@ -206,7 +205,7 @@ public class DanaRNSHistorySync { break; case RecordTypes.RECORD_TYPE_ALARM: if ((what & SYNC_ALARM) == 0) break; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Syncing alarm record " + record.recordAlarm + " " + DateUtil.toISOString(record.recordDate)); nsrec.put(DANARSIGNATURE, record.bytes); nsrec.put("eventType", "Note"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java index f0af9c863a..336c526d82 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/activities/DanaRUserOptionsActivity.java @@ -14,12 +14,12 @@ import org.slf4j.LoggerFactory; import java.text.DecimalFormat; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin; @@ -31,7 +31,7 @@ import info.nightscout.utils.NumberPicker; */ public class DanaRUserOptionsActivity extends Activity { - private static Logger log = LoggerFactory.getLogger(Constants.PUMP); + private static Logger log = LoggerFactory.getLogger(L.PUMP); Switch timeFormat; Switch buttonScroll; @@ -86,7 +86,7 @@ public class DanaRUserOptionsActivity extends Activity { DanaRPump pump = DanaRPump.getInstance(); //used for debugging - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago" + "\ntimeDisplayType:" + pump.timeDisplayType + "\nbuttonScroll:" + pump.buttonScrollOnOff diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java index 31da5c9f21..b48940807d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java @@ -12,8 +12,7 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.utils.CRC; /* @@ -23,7 +22,7 @@ import info.nightscout.utils.CRC; */ public class MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); protected byte[] buffer = new byte[512]; private int position = 6; @@ -96,7 +95,7 @@ public class MessageBase { } public void handleMessage(byte[] bytes) { - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (bytes.length > 6) { int command = (bytes[5] & 0xFF) | ((bytes[4] << 8) & 0xFF00); log.debug("UNPROCESSED MSG: " + getMessageName() + " Command: " + String.format("%04X", command) + " Data: " + toHexString(bytes)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java index 1c656060f0..a285ce5120 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageOriginalNames.java @@ -5,13 +5,13 @@ import org.slf4j.LoggerFactory; import java.util.HashMap; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 28.05.2016. */ public class MessageOriginalNames { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private static HashMap messageNames; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java index dbff4ec3dc..873824f966 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusProgress.java @@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Treatments.Treatment; public class MsgBolusProgress extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private static Treatment t; private static double amount; @@ -28,7 +27,7 @@ public class MsgBolusProgress extends MessageBase { this.amount = amount; this.t = t; lastReceive = System.currentTimeMillis(); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message: amount: " + amount + " treatment: " + t.toString()); } @@ -43,7 +42,7 @@ public class MsgBolusProgress extends MessageBase { bolusingEvent.t = t; bolusingEvent.percent = Math.min((int) (done / amount * 100), 100); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Bolus remaining: " + progress + " delivered: " + done); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java index 7932db46a3..06200d1f0c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStart.java @@ -3,13 +3,12 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.interfaces.Constraint; +import info.nightscout.androidaps.logging.L; public class MsgBolusStart extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public static int errorCode; @@ -25,7 +24,7 @@ public class MsgBolusStart extends MessageBase { AddParamInt((int) (amount * 100)); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Bolus start : " + amount); } @@ -34,10 +33,10 @@ public class MsgBolusStart extends MessageBase { errorCode = intFromBuff(bytes, 0, 1); if (errorCode != 2) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Messsage response: " + errorCode + " FAILED!!"); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Messsage response: " + errorCode + " OK"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java index 5f2a368a58..a3160ff887 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStartWithSpeed.java @@ -3,13 +3,12 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.interfaces.Constraint; +import info.nightscout.androidaps.logging.L; public class MsgBolusStartWithSpeed extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public static int errorCode; @@ -26,7 +25,7 @@ public class MsgBolusStartWithSpeed extends MessageBase { AddParamInt((int) (amount * 100)); AddParamByte((byte) speed); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Bolus start : " + amount + " speed: " + speed); } @@ -35,10 +34,10 @@ public class MsgBolusStartWithSpeed extends MessageBase { errorCode = intFromBuff(bytes, 0, 1); if (errorCode != 2) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Messsage response: " + errorCode + " FAILED!!"); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Messsage response: " + errorCode + " OK"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java index d03a12ea84..fe5d47c131 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgBolusStop.java @@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Treatments.Treatment; public class MsgBolusStop extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private static Treatment t; private static Double amount; @@ -28,13 +27,13 @@ public class MsgBolusStop extends MessageBase { this.t = t; this.amount = amount; forced = false; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Bolus stop: amount: " + amount + " treatment: " + t.toString()); } @Override public void handleMessage(byte[] bytes) { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Messsage received"); EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); stopped = true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java index a8171774b6..e04d9243e7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgCheckValue.java @@ -3,9 +3,8 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; @@ -13,11 +12,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; * Created by mike on 30.06.2016. */ public class MsgCheckValue extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgCheckValue() { SetCommand(0xF0F1); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -26,7 +25,7 @@ public class MsgCheckValue extends MessageBase { DanaRPump pump = DanaRPump.getInstance(); pump.isNewPump = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New firmware confirmed"); pump.model = intFromBuff(bytes, 0, 1); @@ -37,7 +36,7 @@ public class MsgCheckValue extends MessageBase { log.debug("Wrong model selected"); } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Product Code: " + String.format("%02X ", pump.productCode)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java index 8c41d47c7f..b5d4267203 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgError.java @@ -3,19 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; public class MsgError extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgError() { SetCommand(0x0601); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -50,7 +49,7 @@ public class MsgError extends MessageBase { bolusingEvent.status = errorString; MainApp.bus().post(bolusingEvent); } - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Error detected: " + errorString); NSUpload.uploadError(errorString); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java index 686bb3eb85..7adb335e93 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAlarm.java @@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistoryAlarm extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgHistoryAlarm() { SetCommand(0x3105); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } // Handle message taken from MsgHistoryAll diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java index e9da6ef92a..a0e1075056 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAll.java @@ -5,19 +5,18 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.db.DanaRHistoryRecord; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; import info.nightscout.utils.DateUtil; public class MsgHistoryAll extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgHistoryAll() { SetCommand(0x41F2); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java index c4c27da436..e78771f99d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryAllDone.java @@ -3,24 +3,23 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class MsgHistoryAllDone extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public static boolean received = false; public MsgHistoryAllDone() { SetCommand(0x41F1); received = false; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @Override public void handleMessage(byte[] bytes) { received = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("History all done received"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java index d288914395..f56e2af273 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBasalHour.java @@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistoryBasalHour extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgHistoryBasalHour() { SetCommand(0x310A); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } // Handle message taken from MsgHistoryAll diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java index d89891e652..d675ddc488 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryBolus.java @@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistoryBolus extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgHistoryBolus() { SetCommand(0x3101); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } // Handle message taken from MsgHistoryAll diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java index 5114b190c6..6755800bba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryCarbo.java @@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistoryCarbo extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgHistoryCarbo() { SetCommand(0x3107); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } // Handle message taken from MsgHistoryAll diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java index 51765af0d1..68d46f0d20 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDailyInsulin.java @@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistoryDailyInsulin extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgHistoryDailyInsulin() { SetCommand(0x3102); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } // Handle message taken from MsgHistoryAll diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java index a507bef445..63e51e24ba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryDone.java @@ -3,27 +3,26 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistoryDone extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public static boolean received = false; public MsgHistoryDone() { SetCommand(0x31F1); received = false; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @Override public void handleMessage(byte[] bytes) { received = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("History done received"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java index 5c57a4f9f3..8d6d0615d4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryError.java @@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistoryError extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgHistoryError() { SetCommand(0x3106); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } // Handle message taken from MsgHistoryAll diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java index 2eeee09057..10fd68e3ab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryGlucose.java @@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistoryGlucose extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgHistoryGlucose() { SetCommand(0x3104); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } // Handle message taken from MsgHistoryAll diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java index 7213ddef9d..01f7197434 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNew.java @@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistoryNew extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgHistoryNew() { SetCommand(0x42F2); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } // Handle message taken from MsgHistoryAll diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java index 33c820d158..fb9118e629 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryNewDone.java @@ -3,27 +3,26 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistoryNewDone extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public static boolean received = false; public MsgHistoryNewDone() { SetCommand(0x42F1); received = false; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @Override public void handleMessage(byte[] bytes) { received = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("History new done received"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java index 582e76e3ff..238a606cfb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistoryRefill.java @@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistoryRefill extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgHistoryRefill() { SetCommand(0x3108); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } // Handle message taken from MsgHistoryAll diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java index 8d209fc13e..7182722f97 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgHistorySuspend.java @@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 20.07.2016. */ public class MsgHistorySuspend extends MsgHistoryAll { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgHistorySuspend() { SetCommand(0x3109); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } // Handle message taken from MsgHistoryAll diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java index 8d71ed9e1d..61150079cd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBasic.java @@ -3,16 +3,15 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class MsgInitConnStatusBasic extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgInitConnStatusBasic() { SetCommand(0x0303); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -42,7 +41,7 @@ public class MsgInitConnStatusBasic extends MessageBase { boolean deliveryStepBolus = (bolusConfig & DanaRPump.DELIVERY_STEP_BOLUS) != 0; boolean deliveryBasal = (bolusConfig & DanaRPump.DELIVERY_BASAL) != 0; boolean deliveryExtBolus = (bolusConfig & DanaRPump.DELIVERY_EXT_BOLUS) != 0; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Delivery prime: " + deliveryPrime); log.debug("Delivery step bolus: " + deliveryStepBolus); log.debug("Delivery basal: " + deliveryBasal); @@ -52,7 +51,7 @@ public class MsgInitConnStatusBasic extends MessageBase { log.error("Unhadled exception", e); } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump suspended: " + pump.pumpSuspended); log.debug("Calculator enabled: " + pump.calculatorEnabled); log.debug("Daily total units: " + pump.dailyTotalUnits); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java index 163bf7d252..49e00e1bbb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusBolus.java @@ -3,10 +3,9 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; @@ -16,11 +15,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; * Created by mike on 28.05.2016. */ public class MsgInitConnStatusBolus extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgInitConnStatusBolus() { SetCommand(0x0302); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -37,7 +36,7 @@ public class MsgInitConnStatusBolus extends MessageBase { pump.maxBolus = intFromBuff(bytes, 2, 2) / 100d; //int bolusRate = intFromBuff(bytes, 4, 8); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled); log.debug("Bolus increment: " + pump.bolusStep); log.debug("Bolus max: " + pump.maxBolus); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java index 2ff0e77636..c3b73c0ae1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusOption.java @@ -3,19 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** * Created by mike on 28.05.2016. */ public class MsgInitConnStatusOption extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgInitConnStatusOption() { SetCommand(0x0304); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -32,7 +31,7 @@ public class MsgInitConnStatusOption extends MessageBase { //int none = intFromBuff(bytes, 8, 1); if (bytes.length >= 21) { DanaRPump.getInstance().password = intFromBuff(bytes, 9, 2) ^ 0x3463; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Pump password: " + DanaRPump.getInstance().password); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java index 1cb10b0d28..93bea19218 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java @@ -5,12 +5,11 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; @@ -19,11 +18,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; public class MsgInitConnStatusTime extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgInitConnStatusTime() { SetCommand(0x0301); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -56,7 +55,7 @@ public class MsgInitConnStatusTime extends MessageBase { Date time = dateTimeSecFromBuff(bytes, 0); int versionCode = intFromBuff(bytes, 6, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump time: " + time); log.debug("Version code: " + versionCode); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java index ea01c94ad3..6f92c3241c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStart.java @@ -3,21 +3,20 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class MsgPCCommStart extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgPCCommStart() { SetCommand(0x3001); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @Override public void handleMessage(byte[] bytes) { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("PC comm start received"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java index e53d71b611..255bb17532 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgPCCommStop.java @@ -3,20 +3,19 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class MsgPCCommStop extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgPCCommStop() { SetCommand(0x3002); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @Override public void handleMessage(byte[] bytes) { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("PC comm stop received"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java index 8da1f48586..2d222f9601 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetActivateBasalProfile.java @@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class MsgSetActivateBasalProfile extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSetActivateBasalProfile() { SetCommand(0x330C); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -19,7 +18,7 @@ public class MsgSetActivateBasalProfile extends MessageBase { public MsgSetActivateBasalProfile(byte index) { this(); AddParamByte(index); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Activate basal profile: " + index); } @@ -28,10 +27,10 @@ public class MsgSetActivateBasalProfile extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Activate basal profile result: " + result + " FAILED!!!"); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Activate basal profile result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java index c95a49f89f..3e87e4bf41 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetBasalProfile.java @@ -3,19 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; public class MsgSetBasalProfile extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSetBasalProfile() { SetCommand(0x3306); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -26,7 +25,7 @@ public class MsgSetBasalProfile extends MessageBase { for (Integer i = 0; i < 24; i++) { AddParamInt((int) (values[i] * 100)); } - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set basal profile: " + index); } @@ -35,12 +34,12 @@ public class MsgSetBasalProfile extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set basal profile result: " + result + " FAILED!!!"); Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT); MainApp.bus().post(new EventNewNotification(reportFail)); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set basal profile result: " + result); Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60); MainApp.bus().post(new EventNewNotification(reportOK)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java index e446c2498a..59cbcdafa0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetCarbsEntry.java @@ -5,15 +5,14 @@ import org.slf4j.LoggerFactory; import java.util.Calendar; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class MsgSetCarbsEntry extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSetCarbsEntry() { SetCommand(0x0402); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -30,7 +29,7 @@ public class MsgSetCarbsEntry extends MessageBase { AddParamByte((byte) (calendar.get(Calendar.SECOND))); AddParamByte((byte) 0x43); //?? AddParamInt(amount); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set carb entry: " + amount + " date " + calendar.getTime().toString()); } @@ -39,10 +38,10 @@ public class MsgSetCarbsEntry extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set carb entry result: " + result + " FAILED!!!"); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set carb entry result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java index 6de2fc251c..a7f2a0e1b8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStart.java @@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.interfaces.Constraint; +import info.nightscout.androidaps.logging.L; public class MsgSetExtendedBolusStart extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSetExtendedBolusStart() { SetCommand(0x0407); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -27,7 +26,7 @@ public class MsgSetExtendedBolusStart extends MessageBase { AddParamInt((int) (amount * 100)); AddParamByte(halfhours); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set extended bolus start: " + (((int) (amount * 100)) / 100d) + "U halfhours: " + (int) halfhours); } @@ -36,10 +35,10 @@ public class MsgSetExtendedBolusStart extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set extended bolus start result: " + result + " FAILED!!!"); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set extended bolus start result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java index 01060b290d..504db719ea 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetExtendedBolusStop.java @@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class MsgSetExtendedBolusStop extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSetExtendedBolusStop() { SetCommand(0x0406); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -20,10 +19,10 @@ public class MsgSetExtendedBolusStop extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set extended bolus stop result: " + result + " FAILED!!!"); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set extended bolus stop result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java index 9d84650d01..eabf383b94 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetSingleBasalProfile.java @@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; public class MsgSetSingleBasalProfile extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSetSingleBasalProfile() { SetCommand(0x3302); @@ -23,7 +22,7 @@ public class MsgSetSingleBasalProfile extends MessageBase { for (Integer i = 0; i < 24; i++) { AddParamInt((int) (values[i] * 100)); } - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -32,12 +31,12 @@ public class MsgSetSingleBasalProfile extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set basal profile result: " + result + " FAILED!!!"); Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT); MainApp.bus().post(new EventNewNotification(reportFail)); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set basal profile result: " + result); Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60); MainApp.bus().post(new EventNewNotification(reportOK)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java index d688fd9698..c756af3491 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStart.java @@ -3,11 +3,10 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class MsgSetTempBasalStart extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSetTempBasalStart() { SetCommand(0x0401); @@ -25,7 +24,7 @@ public class MsgSetTempBasalStart extends MessageBase { AddParamByte((byte) (percent & 255)); AddParamByte((byte) (durationInHours & 255)); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Temp basal start percent: " + percent + " duration hours: " + durationInHours); } @@ -33,10 +32,10 @@ public class MsgSetTempBasalStart extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set temp basal start result: " + result + " FAILED!!!"); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set temp basal start result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java index dc9812a225..7b14e8e3e3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTempBasalStop.java @@ -3,15 +3,14 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class MsgSetTempBasalStop extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSetTempBasalStop() { SetCommand(0x0403); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Temp basal stop"); } @@ -19,10 +18,10 @@ public class MsgSetTempBasalStop extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set temp basal stop result: " + result + " FAILED!!!"); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set temp basal stop result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java index a5ef58fbd6..6d33aef8cf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetTime.java @@ -5,8 +5,7 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.utils.DateUtil; /** @@ -14,21 +13,21 @@ import info.nightscout.utils.DateUtil; */ public class MsgSetTime extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private static Date time; public MsgSetTime(Date time) { SetCommand(0x330a); this.time = time; AddParamDateTime(time); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message: time:" + DateUtil.dateAndTimeString(time)); } public void handleMessage(byte[] bytes) { int result = intFromBuff(bytes, 0, 1); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Result of setting time: " + time + " is " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java index 02c16aff69..7484966dba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java @@ -3,8 +3,7 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** @@ -12,7 +11,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; */ public class MsgSetUserOptions extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public boolean done; @@ -36,7 +35,7 @@ public class MsgSetUserOptions extends MessageBase { for (int i = 0; i < pump.userOptionsFrompump.length; i++) { AddParamByte(pump.userOptionsFrompump[i]); } - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -44,10 +43,10 @@ public class MsgSetUserOptions extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Setting user options: " + result + " FAILED!!!"); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Setting user options: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingActiveProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingActiveProfile.java index 1261802a23..57ab6367b0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingActiveProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingActiveProfile.java @@ -3,26 +3,25 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** * Created by mike on 05.07.2016. */ public class MsgSettingActiveProfile extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingActiveProfile() { SetCommand(0x320C); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } public void handleMessage(byte[] bytes) { DanaRPump.getInstance().activeProfile = intFromBuff(bytes, 0, 1); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Active profile number: " + DanaRPump.getInstance().activeProfile); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingBasal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingBasal.java index bb9abdc090..899a5a08f0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingBasal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingBasal.java @@ -3,8 +3,7 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; @@ -12,11 +11,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; * Created by mike on 05.07.2016. */ public class MsgSettingBasal extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingBasal() { SetCommand(0x3202); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -30,7 +29,7 @@ public class MsgSettingBasal extends MessageBase { pump.pumpProfiles[pump.activeProfile][index] = basal / 100d; } - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) for (int index = 0; index < 24; index++) { log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[pump.activeProfile][index]); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingBasalProfileAll.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingBasalProfileAll.java index 5f343d89e5..cca35401d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingBasalProfileAll.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingBasalProfileAll.java @@ -3,8 +3,7 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; @@ -15,11 +14,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; * THIS IS BROKEN IN PUMP... SENDING ONLY 1 PROFILE */ public class MsgSettingBasalProfileAll extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingBasalProfileAll() { SetCommand(0x3206); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -44,14 +43,14 @@ public class MsgSettingBasalProfileAll extends MessageBase { for (int index = 0; index < 24; index++) { int basal = intFromBuff(bytes, 59 * profile + 2 * index + 1, 2); if (basal < 10) basal = 0; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("position " + position + " index " + index); pump.pumpProfiles[position][index] = basal / 100d; } } } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (pump.basal48Enable) { for (int profile = 0; profile < 4; profile++) { for (int index = 0; index < 24; index++) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingGlucose.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingGlucose.java index 9256e2df2b..ded78c6272 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingGlucose.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingGlucose.java @@ -3,19 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** * Created by mike on 05.07.2016. */ public class MsgSettingGlucose extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingGlucose() { SetCommand(0x3209); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -24,7 +23,7 @@ public class MsgSettingGlucose extends MessageBase { pump.units = intFromBuff(bytes, 0, 1); pump.easyBasalMode = intFromBuff(bytes, 1, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Easy basal mode: " + pump.easyBasalMode); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMaxValues.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMaxValues.java index 4d888155da..3c640e1870 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMaxValues.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMaxValues.java @@ -3,8 +3,7 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; @@ -12,11 +11,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; * Created by mike on 05.07.2016. */ public class MsgSettingMaxValues extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingMaxValues() { SetCommand(0x3205); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -26,7 +25,7 @@ public class MsgSettingMaxValues extends MessageBase { pump.maxBasal = intFromBuff(bytes, 2, 2) / 100d; pump.maxDailyTotalUnits = intFromBuff(bytes, 4, 2) / 100; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Max bolus: " + pump.maxBolus); log.debug("Max basal: " + pump.maxBasal); log.debug("Total daily max units: " + pump.maxDailyTotalUnits); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java index 54d45ccfcf..558b8953c0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java @@ -3,11 +3,10 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; @@ -19,11 +18,11 @@ import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; */ public class MsgSettingMeal extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingMeal() { SetCommand(0x3203); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -36,7 +35,7 @@ public class MsgSettingMeal extends MessageBase { int blockTime = intFromBuff(bytes, 4, 1); pump.isConfigUD = intFromBuff(bytes, 5, 1) == 1; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Basal step: " + pump.basalStep); log.debug("Bolus step: " + pump.bolusStep); log.debug("Bolus enabled: " + bolusEnabled); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingProfileRatios.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingProfileRatios.java index 480a38f85e..5b6ea9b6cf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingProfileRatios.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingProfileRatios.java @@ -3,19 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** * Created by mike on 05.07.2016. */ public class MsgSettingProfileRatios extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingProfileRatios() { SetCommand(0x3204); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -35,7 +34,7 @@ public class MsgSettingProfileRatios extends MessageBase { pump.currentAIDR = intFromBuff(bytes, 8, 1); } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump units (saved): " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Current pump CIR: " + pump.currentCIR); log.debug("Current pump CF: " + pump.currentCF); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingProfileRatiosAll.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingProfileRatiosAll.java index b754fe0818..10d424657b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingProfileRatiosAll.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingProfileRatiosAll.java @@ -3,19 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** * Created by mike on 05.07.2016. */ public class MsgSettingProfileRatiosAll extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingProfileRatiosAll() { SetCommand(0x320D); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -41,7 +40,7 @@ public class MsgSettingProfileRatiosAll extends MessageBase { pump.nightCF = intFromBuff(bytes, 14, 2) / 100d; } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Current pump morning CIR: " + pump.morningCIR); log.debug("Current pump morning CF: " + pump.morningCF); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingPumpTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingPumpTime.java index 7721b6f1a4..e50f5b4841 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingPumpTime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingPumpTime.java @@ -5,16 +5,15 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class MsgSettingPumpTime extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingPumpTime() { SetCommand(0x320A); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -29,7 +28,7 @@ public class MsgSettingPumpTime extends MessageBase { intFromBuff(bytes, 0, 1) ); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Pump time: " + time + " Phone time: " + new Date()); DanaRPump.getInstance().pumpTime = time; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingShippingInfo.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingShippingInfo.java index ae872767bb..b700b0baa0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingShippingInfo.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingShippingInfo.java @@ -3,19 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** * Created by mike on 05.07.2016. */ public class MsgSettingShippingInfo extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingShippingInfo() { SetCommand(0x3207); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -24,7 +23,7 @@ public class MsgSettingShippingInfo extends MessageBase { pump.serialNumber = stringFromBuff(bytes, 0, 10); pump.shippingDate = dateFromBuff(bytes, 10); pump.shippingCountry = asciiStringFromBuff(bytes, 13, 3); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Serial number: " + pump.serialNumber); log.debug("Shipping date: " + pump.shippingDate); log.debug("Shipping country: " + pump.shippingCountry); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java index 48f799f0fb..e45e2050db 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java @@ -5,8 +5,7 @@ import org.slf4j.LoggerFactory; import java.util.Arrays; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** @@ -15,11 +14,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class MsgSettingUserOptions extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingUserOptions() { SetCommand(0x320B); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -46,7 +45,7 @@ public class MsgSettingUserOptions extends MessageBase { int selectableLanguage5 = bytes[14]; */ - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("timeDisplayType: " + pump.timeDisplayType); log.debug("Button scroll: " + pump.buttonScrollOnOff); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatus.java index 9f76baa284..474c29daa1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatus.java @@ -3,16 +3,15 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class MsgStatus extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgStatus() { SetCommand(0x020B); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -29,7 +28,7 @@ public class MsgStatus extends MessageBase { } pump.iob = intFromBuff(bytes, 15, 2) / 100d; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Daily total: " + pump.dailyTotalUnits); log.debug("Is extended bolus running: " + pump.isExtendedInProgress); log.debug("Extended bolus min: " + pump.extendedBolusMinutes); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusBasic.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusBasic.java index dc550a5174..8f81220885 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusBasic.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusBasic.java @@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class MsgStatusBasic extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgStatusBasic() { SetCommand(0x020A); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -33,7 +32,7 @@ public class MsgStatusBasic extends MessageBase { //pump.isTempBasalInProgress = intFromBuff(bytes, 15, 1) == 1; pump.batteryRemaining = intFromBuff(bytes, 20, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump suspended: " + pump.pumpSuspended); log.debug("Calculator enabled: " + pump.calculatorEnabled); log.debug("Daily total units: " + pump.dailyTotalUnits); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusBolusExtended.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusBolusExtended.java index 0e7fb2d5cc..72f5a98dbf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusBolusExtended.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusBolusExtended.java @@ -7,20 +7,19 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.interfaces.TreatmentsInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; public class MsgStatusBolusExtended extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgStatusBolusExtended() { SetCommand(0x0207); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -51,7 +50,7 @@ public class MsgStatusBolusExtended extends MessageBase { updateExtendedBolusInDB(); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Is extended bolus running: " + isExtendedInProgress); log.debug("Extended bolus min: " + extendedBolusMinutes); log.debug("Extended bolus amount: " + extendedBolusAmount); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusProfile.java index 70bbda2e08..079357c6ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusProfile.java @@ -3,19 +3,18 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** * Created by mike on 05.07.2016. */ public class MsgStatusProfile extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgStatusProfile() { SetCommand(0x0204); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -33,7 +32,7 @@ public class MsgStatusProfile extends MessageBase { pump.currentTarget = intFromBuff(bytes, 6, 2) / 100d; } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump units (saved): " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Current pump CIR: " + pump.currentCIR); log.debug("Current pump CF: " + pump.currentCF); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusTempBasal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusTempBasal.java index 4b81e4eae0..05436956e8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusTempBasal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgStatusTempBasal.java @@ -7,19 +7,18 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; public class MsgStatusTempBasal extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgStatusTempBasal() { SetCommand(0x0205); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -45,7 +44,7 @@ public class MsgStatusTempBasal extends MessageBase { updateTempBasalInDB(); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Is temp basal running: " + isTempBasalInProgress); log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress); log.debug("Current temp basal percent: " + tempBasalPercent); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java index cb6ff28d03..d800301cfc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java @@ -17,13 +17,12 @@ import java.io.IOException; import java.util.Set; import java.util.UUID; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.events.EventPumpStatusChanged; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStop; @@ -49,7 +48,7 @@ import info.nightscout.utils.ToastUtils; */ public abstract class AbstractDanaRExecutionService extends Service { - protected Logger log = LoggerFactory.getLogger(Constants.PUMP); + protected Logger log = LoggerFactory.getLogger(L.PUMP); protected String mDevName; @@ -102,7 +101,7 @@ public abstract class AbstractDanaRExecutionService extends Service { BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); String action = intent.getAction(); if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Device was disconnected " + device.getName());//Device was disconnected if (mBTDevice != null && mBTDevice.getName() != null && mBTDevice.getName().equals(device.getName())) { if (mSerialIOThread != null) { @@ -169,7 +168,7 @@ public abstract class AbstractDanaRExecutionService extends Service { } public void bolusStop() { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("bolusStop >>>>> @ " + (mBolusingTreatment == null ? "" : mBolusingTreatment.insulin)); MsgBolusStop stop = new MsgBolusStop(); stop.forced = true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java index 22c7f8187b..0f1dc5dbf9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java @@ -10,7 +10,6 @@ import com.squareup.otto.Subscribe; import java.io.IOException; import java.util.Date; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -22,6 +21,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventProfileSwitchChange; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; @@ -193,13 +193,13 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime))); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Pump time difference: " + timeDiff + " seconds"); if (Math.abs(timeDiff) > 10) { mSerialIOThread.sendMessage(new MsgSetTime(new Date())); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Pump time difference: " + timeDiff + " seconds"); } mDanaRPump.lastSettingsRead = now; @@ -209,7 +209,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventInitializationChanged()); NSUpload.uploadDeviceStatus(); if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits); if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT); @@ -301,7 +301,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm stop.stopped = true; stop.forced = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Communication stopped"); } } @@ -345,10 +345,10 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { public void run() { if (mDanaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old t.insulin = mDanaRPump.lastBolusAmount; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Used bolus amount from history: " + mDanaRPump.lastBolusAmount); } else { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Bolus amount in history too old: " + mDanaRPump.lastBolusTime.toLocaleString()); } synchronized (o) { @@ -402,7 +402,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { @Subscribe public void onStatusEvent(EventAppExit event) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("EventAppExit received"); if (mSerialIOThread != null) @@ -411,7 +411,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { MainApp.instance().getApplicationContext().unregisterReceiver(receiver); stopSelf(); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("EventAppExit finished"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java index 2e8aac4643..327a8a5dea 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java @@ -11,7 +11,6 @@ import android.support.v7.app.AlertDialog; import com.squareup.otto.Subscribe; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -24,6 +23,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStart; @@ -93,14 +93,14 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.invoke(); SP.putBoolean("allow_hardware_pump", true); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("First time HW pump allowed!"); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.cancel(); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("User does not allow switching to HW pump!"); } }); @@ -129,13 +129,13 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Service is disconnected"); sExecutionService = null; } public void onServiceConnected(ComponentName name, IBinder service) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Service is connected"); DanaRKoreanExecutionService.LocalBinder mLocalBinder = (DanaRKoreanExecutionService.LocalBinder) service; sExecutionService = mLocalBinder.getServiceInstance(); @@ -199,7 +199,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStart.errorCode); else result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.date = System.currentTimeMillis(); @@ -241,13 +241,13 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { if (doTempOff) { // If extended in progress if (activeExtended != null && useExtendedBoluses) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)"); return cancelExtendedBolus(); } // If temp in progress if (activeTemp != null) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); return cancelRealTempBasal(); } @@ -256,7 +256,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.percent = 100; result.isPercent = true; result.isTempCancel = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: doTempOff OK"); return result; } @@ -268,12 +268,12 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { if (percentRate > getPumpDescription().maxTempPercent) { percentRate = getPumpDescription().maxTempPercent; } - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate); // If extended in progress if (activeExtended != null && useExtendedBoluses) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)"); result = cancelExtendedBolus(); if (!result.success) { @@ -284,7 +284,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { // Check if some temp is already in progress if (activeTemp != null) { // Correct basal already set ? - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString()); if (activeTemp.percentRate == percentRate) { if (enforceNew) { @@ -296,21 +296,21 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.duration = activeTemp.getPlannedRemainingMinutes(); result.isPercent = true; result.isTempCancel = false; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); return result; } } } // Convert duration from minutes to hours - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); return setTempBasalPercent(percentRate, durationInMinutes, profile, false); } if (doExtendedTemp) { // Check if some temp is already in progress if (activeTemp != null) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)"); result = cancelRealTempBasal(); // Check for proper result @@ -329,7 +329,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours // What is current rate of extended bolusing in u/h? - if (Config.logPump) { + if (L.isEnabled(L.PUMP)) { log.debug("setTempBasalAbsolute: Extended bolus in progress: " + (activeExtended != null) + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min"); log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h"); } @@ -343,21 +343,21 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.duration = pump.extendedBolusRemainingMinutes; result.isPercent = false; result.isTempCancel = false; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Correct extended already set"); return result; } // Now set new extended, no need to to stop previous (if running) because it's replaced Double extendedAmount = extendedRateToSet / 2 * durationInHalfHours; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Setting extended: " + extendedAmount + "U halfhours: " + durationInHalfHours); result = setExtendedBolus(extendedAmount, durationInMinutes); if (!result.success) { log.error("setTempBasalAbsolute: Failed to set extended bolus"); return result; } - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Extended bolus set ok"); result.absolute = result.absolute + getBaseBasalRate(); return result; @@ -396,7 +396,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { result.success = true; result.isTempCancel = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("cancelRealTempBasal: OK"); return result; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java index 6a36e565a9..ea12b2b9c4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/SerialIOThread.java @@ -10,8 +10,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread; @@ -22,7 +21,7 @@ import info.nightscout.utils.CRC; * Created by mike on 17.07.2016. */ public class SerialIOThread extends AbstractSerialIOThread { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPBTCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPBTCOMM); private InputStream mInputStream = null; private OutputStream mOutputStream = null; @@ -73,7 +72,7 @@ public class SerialIOThread extends AbstractSerialIOThread { message = MessageHashTable_k.findMessage(command); } - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff)); // process the message content @@ -149,7 +148,7 @@ public class SerialIOThread extends AbstractSerialIOThread { processedMessage = message; byte[] messageBytes = message.getRawMessageBytes(); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes)); try { @@ -168,7 +167,7 @@ public class SerialIOThread extends AbstractSerialIOThread { SystemClock.sleep(200); if (!message.received) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.warn("Reply not received " + message.getMessageName()); if (message.getCommand() == 0xF0F1) { DanaRPump.getInstance().isNewPump = false; @@ -183,28 +182,28 @@ public class SerialIOThread extends AbstractSerialIOThread { try { mInputStream.close(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } try { mOutputStream.close(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } try { mRfCommSocket.close(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } try { System.runFinalization(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("Disconnected: " + reason); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java index 0f08000a5a..7bde73d5a1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgCheckValue_k.java @@ -3,24 +3,20 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; -import info.nightscout.utils.ToastUtils; /** * Created by mike on 30.06.2016. */ public class MsgCheckValue_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgCheckValue_k() { SetCommand(0xF0F1); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -29,7 +25,7 @@ public class MsgCheckValue_k extends MessageBase { DanaRPump pump = DanaRPump.getInstance(); pump.isNewPump = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("New firmware confirmed"); pump.model = intFromBuff(bytes, 0, 1); @@ -40,7 +36,7 @@ public class MsgCheckValue_k extends MessageBase { log.error("Wrong model selected"); } - if (Config.logPump) { + if (L.isEnabled(L.PUMP)) { log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Product Code: " + String.format("%02X ", pump.productCode)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java index 6eefefe34c..46222938d7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBasic_k.java @@ -3,10 +3,9 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; @@ -14,11 +13,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgInitConnStatusBasic_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgInitConnStatusBasic_k() { SetCommand(0x0303); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -33,7 +32,7 @@ public class MsgInitConnStatusBasic_k extends MessageBase { pump.isEasyModeEnabled = intFromBuff(bytes, 2, 1) == 1; int easyUIMode = intFromBuff(bytes, 3, 1); pump.password = intFromBuff(bytes, 4, 2) ^ 0x3463; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("isStatusSuspendOn: " + pump.pumpSuspended); log.debug("isUtilityEnable: " + isUtilityEnable); log.debug("Is EasyUI Enabled: " + pump.isEasyModeEnabled); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java index 4412457b09..4be04f538f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusBolus_k.java @@ -3,10 +3,9 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; @@ -17,11 +16,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; * Created by mike on 28.05.2016. */ public class MsgInitConnStatusBolus_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgInitConnStatusBolus_k() { SetCommand(0x0302); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -39,7 +38,7 @@ public class MsgInitConnStatusBolus_k extends MessageBase { //int bolusRate = intFromBuff(bytes, 4, 8); int deliveryStatus = intFromBuff(bytes, 12, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Is Extended bolus enabled: " + pump.isExtendedBolusEnabled); log.debug("Bolus increment: " + pump.bolusStep); log.debug("Bolus max: " + pump.maxBolus); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java index 8f4642999a..5aadfeae42 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java @@ -5,12 +5,11 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; @@ -20,11 +19,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; public class MsgInitConnStatusTime_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgInitConnStatusTime_k() { SetCommand(0x0301); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -61,7 +60,7 @@ public class MsgInitConnStatusTime_k extends MessageBase { int versionCode3 = intFromBuff(bytes, 8, 1); int versionCode4 = intFromBuff(bytes, 9, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump time: " + time); log.debug("Version code1: " + versionCode1); log.debug("Version code2: " + versionCode2); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java index 9890201485..2455f59e14 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasalProfileAll_k.java @@ -3,8 +3,7 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; @@ -16,11 +15,11 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; * THIS IS BROKEN IN PUMP... SENDING ONLY 1 PROFILE */ public class MsgSettingBasalProfileAll_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingBasalProfileAll_k() { SetCommand(0x3206); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -52,7 +51,7 @@ public class MsgSettingBasalProfileAll_k extends MessageBase { } } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (pump.basal48Enable) { for (int profile = 0; profile < 4; profile++) { for (int index = 0; index < 24; index++) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java index c5767e1bbc..b149ceb2ad 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgSettingBasal_k.java @@ -3,8 +3,7 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; @@ -13,11 +12,11 @@ import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; * Created by mike on 05.07.2016. */ public class MsgSettingBasal_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSettingBasal_k() { SetCommand(0x3202); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -31,7 +30,7 @@ public class MsgSettingBasal_k extends MessageBase { pump.pumpProfiles[pump.activeProfile][index] = basal / 100d; } - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) for (int index = 0; index < 24; index++) { log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[pump.activeProfile][index]); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java index f905593db0..d22c6e376a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatusBasic_k.java @@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgStatusBasic_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgStatusBasic_k() { SetCommand(0x020A); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -32,7 +31,7 @@ public class MsgStatusBasic_k extends MessageBase { pump.currentBasal = currentBasal; pump.batteryRemaining = batteryRemaining; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Daily total units: " + dailyTotalUnits); log.debug("Max daily total units: " + maxDailyTotalUnits); log.debug("Reservoir remaining units: " + reservoirRemainingUnits); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java index c81f010f16..4d8b012244 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgStatus_k.java @@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaRKorean.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgStatus_k extends MessageBase { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgStatus_k() { SetCommand(0x020B); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -30,7 +29,7 @@ public class MsgStatus_k extends MessageBase { // } pump.iob = intFromBuff(bytes, 15, 2) / 100d; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Daily total: " + pump.dailyTotalUnits); log.debug("Is extended bolus running: " + pump.isExtendedInProgress); log.debug("Extended bolus min: " + pump.extendedBolusMinutes); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java index 579aa916d2..e54dd7be83 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java @@ -10,7 +10,6 @@ import com.squareup.otto.Subscribe; import java.io.IOException; import java.util.Date; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -22,6 +21,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventProfileSwitchChange; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; @@ -83,7 +83,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { @Subscribe public void onStatusEvent(EventAppExit event) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("EventAppExit received"); if (mSerialIOThread != null) @@ -92,7 +92,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { MainApp.instance().getApplicationContext().unregisterReceiver(receiver); stopSelf(); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("EventAppExit finished"); } @@ -193,13 +193,13 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime))); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Pump time difference: " + timeDiff + " seconds"); if (Math.abs(timeDiff) > 10) { mSerialIOThread.sendMessage(new MsgSetTime(new Date())); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Pump time difference: " + timeDiff + " seconds"); } mDanaRPump.lastSettingsRead = now; @@ -209,7 +209,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventInitializationChanged()); NSUpload.uploadDeviceStatus(); if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits); if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT); @@ -296,7 +296,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm stop.stopped = true; stop.forced = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Communication stopped"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java index 613d77a44d..ae314f77a7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java @@ -20,8 +20,6 @@ import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.BuildConfig; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -40,6 +38,7 @@ import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; @@ -65,7 +64,7 @@ import info.nightscout.utils.T; */ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface, ProfileInterface { - private Logger log = LoggerFactory.getLogger(Constants.PUMP); + private Logger log = LoggerFactory.getLogger(L.PUMP); private static DanaRSPlugin plugin = null; public static DanaRSPlugin getPlugin() { @@ -165,14 +164,14 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte public void onClick(DialogInterface dialog, int id) { pluginSwitcher.invoke(); SP.putBoolean("allow_hardware_pump", true); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("First time HW pump allowed!"); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.cancel(); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("User does not allow switching to HW pump!"); } }); @@ -183,13 +182,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Service is disconnected"); danaRSService = null; } public void onServiceConnected(ComponentName name, IBinder service) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Service is connected"); DanaRSService.LocalBinder mLocalBinder = (DanaRSService.LocalBinder) service; danaRSService = mLocalBinder.getServiceInstance(); @@ -210,7 +209,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte @Override public void connect(String from) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("RS connect from: " + from); if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) { final Object o = new Object(); @@ -231,7 +230,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte @Override public void disconnect(String from) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("RS disconnect from: " + from); if (danaRSService != null) danaRSService.disconnect(from); } @@ -378,7 +377,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte Double profileValue = profile.getBasalTimeFromMidnight((Integer) (h * basalIncrement)); if (profileValue == null) return true; if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); return false; } @@ -439,7 +438,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, DanaRS_Packet_Bolus_Set_Step_Bolus_Start.errorCode); else result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); return result; } else { @@ -483,7 +482,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte if (doTempOff) { // If temp in progress if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); return cancelTempBasal(false); } @@ -492,7 +491,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.percent = 100; result.isPercent = true; result.isTempCancel = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: doTempOff OK"); return result; } @@ -506,7 +505,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte // Check if some temp is already in progress TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()); if (activeTemp != null) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString()); // Correct basal already set ? if (activeTemp.percentRate == percentRate) { @@ -517,14 +516,14 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = activeTemp.getPlannedRemainingMinutes(); result.isPercent = true; result.isTempCancel = false; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); return result; } } } // Convert duration from minutes to hours - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); if (percentRate == 0 && durationInMinutes > 30) { result = setTempBasalPercent(percentRate, durationInMinutes, profile, false); @@ -536,7 +535,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte log.error("setTempBasalAbsolute: Failed to set hightemp basal"); return result; } - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: hightemp basal set ok"); return result; } @@ -571,7 +570,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalPercent: Correct value already set"); return result; } @@ -590,7 +589,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalPercent: OK"); return result; } @@ -612,7 +611,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setHighTempBasalPercent: OK"); return result; } @@ -639,7 +638,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.absolute = pump.extendedBolusAbsoluteRate; result.isPercent = false; result.isTempCancel = false; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin); return result; } @@ -653,7 +652,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.absolute = pump.extendedBolusAbsoluteRate; result.bolusDelivered = pump.extendedBolusAmount; result.isPercent = false; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setExtendedBolus: OK"); return result; } @@ -677,7 +676,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte result.success = true; result.isTempCancel = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("cancelRealTempBasal: OK"); return result; } else { @@ -701,7 +700,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte if (!pump.isExtendedInProgress) { result.success = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("cancelExtendedBolus: OK"); return result; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java index 9827d42ba7..bda5d42207 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRSMessageHashTable.java @@ -1,11 +1,8 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.HashMap; -import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 28.05.2016. @@ -15,9 +12,6 @@ public class DanaRSMessageHashTable { static { if (messages == null) { - boolean savedState = Config.logPumpComm; - Config.logPumpComm = false; - messages = new HashMap<>(); put(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal()); put(new DanaRS_Packet_Basal_Get_Basal_Rate()); @@ -87,7 +81,6 @@ public class DanaRSMessageHashTable { put(new DanaRS_Packet_APS_History_Events()); put(new DanaRS_Packet_APS_Set_Event_History()); - Config.logPumpComm = savedState; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java index b145c0d8fe..c33cd7b405 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java @@ -5,11 +5,10 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); int temporaryBasalRatio; int temporaryBasalDuration; @@ -26,7 +25,7 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { public DanaRS_Packet_APS_Basal_Set_Temporary_Basal(int percent) { this(); setParams(percent); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message: percent: " + percent); } @@ -38,11 +37,11 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { temporaryBasalRatio = percent; if (percent < 100) { temporaryBasalDuration = PARAM30MIN; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("APS Temp basal start percent: " + percent + " duration 30 min"); } else { temporaryBasalDuration = PARAM15MIN; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("APS Temp basal start percent: " + percent + " duration 15 min"); } } @@ -60,11 +59,11 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { temporaryBasalRatio = percent; if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200% temporaryBasalDuration = PARAM30MIN; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("APS Temp basal start percent: " + percent + " duration 30 min"); } else { temporaryBasalDuration = PARAM15MIN; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("APS Temp basal start percent: " + percent + " duration 15 min"); } } @@ -83,11 +82,11 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { int result = byteArrayToInt(getBytes(data, DATA_START, 1)); if (result != 0) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set APS temp basal start result: " + result + " FAILED!!!"); } else { failed = false; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set APS temp basal start result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java index 76994861fb..60e640bc77 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java @@ -9,8 +9,6 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -18,13 +16,14 @@ import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.events.EventPumpStatusChanged; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.utils.DateUtil; public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int year = 0; private int month = 0; @@ -56,7 +55,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { hour = cal.get(Calendar.HOUR_OF_DAY); min = cal.get(Calendar.MINUTE); sec = cal.get(Calendar.SECOND); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString()); } @@ -79,7 +78,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { // Last record if (recordCode == (byte) 0xFF) { done = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Last record received"); return; } @@ -97,11 +96,11 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime()); if (detailedBolusInfo == null) { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Detailed bolus info not found for " + datetime.toLocaleString()); detailedBolusInfo = new DetailedBolusInfo(); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Detailed bolus info found: " + detailedBolusInfo); } detailedBolusInfo.date = datetime.getTime(); @@ -112,7 +111,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { switch (recordCode) { case DanaRPump.TEMPSTART: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); temporaryBasal.percentRate = param1; temporaryBasal.durationInMinutes = param2; @@ -120,13 +119,13 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { status = "TEMPSTART " + DateUtil.timeString(datetime); break; case DanaRPump.TEMPSTOP: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal); status = "TEMPSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTART: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; @@ -134,7 +133,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { status = "EXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTOP: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "EXTENDEDSTOP " + DateUtil.timeString(datetime); @@ -142,7 +141,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { case DanaRPump.BOLUS: detailedBolusInfo.insulin = param1 / 100d; boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); status = "BOLUS " + DateUtil.timeString(datetime); @@ -150,13 +149,13 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { case DanaRPump.DUALBOLUS: detailedBolusInfo.insulin = param1 / 100d; newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); status = "DUALBOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTART: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; @@ -164,33 +163,33 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTOP: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDON: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); status = "SUSPENDON " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDOFF: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); status = "SUSPENDOFF " + DateUtil.timeString(datetime); break; case DanaRPump.REFILL: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); status = "REFILL " + DateUtil.timeString(datetime); break; case DanaRPump.PRIME: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); status = "PRIME " + DateUtil.timeString(datetime); break; case DanaRPump.PROFILECHANGE: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); status = "PROFILECHANGE " + DateUtil.timeString(datetime); break; @@ -201,17 +200,17 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { emptyCarbsInfo.source = Source.PUMP; emptyCarbsInfo.pumpId = datetime.getTime(); newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); status = "CARBS " + DateUtil.timeString(datetime); break; case DanaRPump.PRIMECANNULA: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); status = "PRIMECANNULA " + DateUtil.timeString(datetime); break; default: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); status = "UNKNOWN " + DateUtil.timeString(datetime); break; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java index efd3aaa8f4..2a5e9eade6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java @@ -8,12 +8,11 @@ import org.slf4j.LoggerFactory; import java.util.Calendar; import java.util.GregorianCalendar; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.utils.DateUtil; public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int type; private long time; @@ -32,7 +31,7 @@ public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet { this.time = time; this.param1 = param1; this.param2 = param2; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set history entry: " + DateUtil.dateAndTimeString(time) + " type: " + type + " param1: " + param1 + " param2: " + param2); } @@ -67,10 +66,10 @@ public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet { int result = intFromBuff(data, 0, 1); if (result != 0) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.error("Set history entry result: " + result + " FAILED!!!"); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set history entry result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java index f358cbdcd0..a067d2976d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java @@ -6,23 +6,22 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Basal_Get_Basal_Rate() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Requesting basal rates"); } } @@ -46,7 +45,7 @@ public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet { dataSize = 2; pump.pumpProfiles[pump.activeProfile][i] = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Max basal: " + pump.maxBasal + " U"); log.debug("Basal step: " + pump.basalStep + " U"); for (int index = 0; index < 24; index++) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java index 2b4e830644..8cc73ac3a6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Basal_Rate.java @@ -5,12 +5,11 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int profileNumber; @@ -23,7 +22,7 @@ public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet { public DanaRS_Packet_Basal_Get_Profile_Basal_Rate(int profileNumber) { this(); this.profileNumber = profileNumber; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Requesting basal rates for profile " + profileNumber); } } @@ -49,7 +48,7 @@ public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet { dataIndex += dataSize; dataSize = 2; } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { for (int index = 0; index < 24; index++) log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[profileNumber][index]); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java index c376a35cba..1beadfd705 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Profile_Number.java @@ -5,17 +5,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Basal_Get_Profile_Number extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Basal_Get_Profile_Number() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Requesting active profile"); } } @@ -27,7 +26,7 @@ public class DanaRS_Packet_Basal_Get_Profile_Number extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; pump.activeProfile = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Active profile: " + pump.activeProfile); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java index 0b892c8335..c6f434d1ba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Temporary_Basal_State.java @@ -9,17 +9,16 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Basal_Get_Temporary_Basal_State() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Requesting temporary basal status"); } } @@ -55,7 +54,7 @@ public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet int tempBasalRemainingMin = (pump.tempBasalTotalSec - runningMin * 60) / 60; Date tempBasalStart = pump.isTempBasalInProgress ? getDateFromTempBasalSecAgo(runningMin * 60) : new Date(0); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Error code: " + error); log.debug("Is temp basal running: " + pump.isTempBasalInProgress); log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java index bf6f6922a0..19b53ba53c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java @@ -3,13 +3,12 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private double[] profileBasalRate; @@ -21,7 +20,7 @@ public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { public DanaRS_Packet_Basal_Set_Basal_Rate(double[] profileBasalRate) { this(); this.profileBasalRate = profileBasalRate; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Setting new basal rates"); } } @@ -40,7 +39,7 @@ public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java index 667360202d..e8a288a258 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java @@ -5,16 +5,15 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Canceling temp basal"); } } @@ -22,7 +21,7 @@ public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packe @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java index 29df6e69ac..004e9d69b2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java @@ -5,11 +5,10 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int profileNumber; // 0 - 4 private double[] profileBasalRate; @@ -23,7 +22,7 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet { this(); this.profileNumber = profileNumber; this.profileBasalRate = profileBasalRate; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Setting new basal rates for profile " + profileNumber); } } @@ -43,7 +42,7 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java index dcb03a89ae..613c3d6f8b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java @@ -5,11 +5,10 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int profileNumber; public DanaRS_Packet_Basal_Set_Profile_Number() { @@ -20,7 +19,7 @@ public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet { public DanaRS_Packet_Basal_Set_Profile_Number(int profileNumber) { this(); this.profileNumber = profileNumber; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Setting profile number " + profileNumber); } } @@ -35,7 +34,7 @@ public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java index 7614488a78..2c4c46eb2e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java @@ -5,16 +5,15 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Basal_Set_Suspend_Off() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Turning off suspend"); } } @@ -22,7 +21,7 @@ public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java index 72049bc033..25d55968a9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java @@ -5,16 +5,15 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Basal_Set_Suspend_On() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Turning on suspend"); } } @@ -22,7 +21,7 @@ public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java index fa23fa08f8..15de10f742 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java @@ -5,11 +5,10 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int temporaryBasalRatio; private int temporaryBasalDuration; @@ -23,7 +22,7 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet { this(); this.temporaryBasalRatio = temporaryBasalRatio; this.temporaryBasalDuration = temporaryBasalDuration; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Setting temporary basal of " + temporaryBasalRatio + "% for " + temporaryBasalDuration + " hours"); } } @@ -39,7 +38,7 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java index 84b0bf1736..e2c5d5fae6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Bolus_Option.java @@ -5,22 +5,21 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Bolus_Option extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Bolus_Option() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_OPTION; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -111,7 +110,7 @@ public class DanaRS_Packet_Bolus_Get_Bolus_Option extends DanaRS_Packet { MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED)); } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Extended bolus enabled: " + pump.isExtendedBolusEnabled); log.debug("Missed bolus config: " + pump.missedBolusConfig); log.debug("missedBolus01StartHour: " + missedBolus01StartHour); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java index fd4f942d1b..2a834806f6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_CIR_CF_Array.java @@ -6,17 +6,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_CIR_CF_Array extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Bolus_Get_CIR_CF_Array() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CIR_CF_ARRAY; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -120,7 +119,7 @@ public class DanaRS_Packet_Bolus_Get_CIR_CF_Array extends DanaRS_Packet { pump.nightCF = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Language: " + language); log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Current pump morning CIR: " + pump.morningCIR); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java index a16368a8b3..67768df866 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Calculation_Information.java @@ -5,17 +5,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Calculation_Information extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Calculation_Information() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CALCULATION_INFORMATION; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -60,7 +59,7 @@ public class DanaRS_Packet_Bolus_Get_Calculation_Information extends DanaRS_Pack pump.currentTarget = pump.currentTarget / 100d; currentBG = currentBG / 100d; } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Result: " + error); log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL")); log.debug("Current BG: " + currentBG); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java index deb68ebac9..ba93dde999 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information.java @@ -5,17 +5,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -35,7 +34,7 @@ public class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information extend dataSize = 2; pump.currentCIR = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Result: " + error); log.debug("Carbs: " + carbs); log.debug("Current CIR: " + pump.currentCIR); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java index 7c5aaf7e9e..230a9d2480 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Dual_Bolus.java @@ -5,17 +5,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Dual_Bolus extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Dual_Bolus() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_DUAL_BOLUS; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -43,7 +42,7 @@ public class DanaRS_Packet_Bolus_Get_Dual_Bolus extends DanaRS_Packet { dataSize = 1; double bolusIncrement = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Result: " + error); log.debug("Bolus step: " + pump.bolusStep + " U"); log.debug("Extended bolus running: " + pump.extendedBolusAbsoluteRate + " U/h"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java index bd7b1fb38a..695f21c0a1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus.java @@ -5,17 +5,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Extended_Bolus extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Extended_Bolus() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -39,7 +38,7 @@ public class DanaRS_Packet_Bolus_Get_Extended_Bolus extends DanaRS_Packet { dataSize = 1; pump.bolusStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Result: " + error); log.debug("Extended bolus running: " + pump.extendedBolusAbsoluteRate + " U/h"); log.debug("Max bolus: " + pump.maxBolus + " U"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java index a793de020c..95c96ea322 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Bolus_State.java @@ -5,17 +5,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Extended_Bolus_State extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Extended_Bolus_State() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS_STATE; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -47,7 +46,7 @@ public class DanaRS_Packet_Bolus_Get_Extended_Bolus_State extends DanaRS_Packet dataSize = 2; pump.extendedBolusDeliveredSoFar = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Result: " + error); log.debug("Is extended bolus running: " + pump.isExtendedInProgress); log.debug("Extended bolus running: " + pump.extendedBolusAbsoluteRate + " U/h"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java index e6512522a8..fda8778d08 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State.java @@ -5,17 +5,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_MENU_OPTION_STATE; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -31,7 +30,7 @@ public class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State extends DanaRS_P dataSize = 1; pump.isExtendedInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("extendedMenuOption: " + extendedMenuOption); log.debug("Is extended bolus running: " + pump.isExtendedInProgress); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java index 6b67bd66e7..d52bd50ea1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Initial_Bolus.java @@ -5,16 +5,15 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Bolus_Get_Initial_Bolus extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Initial_Bolus() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_RATE; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -35,7 +34,7 @@ public class DanaRS_Packet_Bolus_Get_Initial_Bolus extends DanaRS_Packet { dataIndex += dataSize; dataSize = 2; double initialBolusValue04 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Initial bolus amount 01: " + initialBolusValue01); log.debug("Initial bolus amount 02: " + initialBolusValue02); log.debug("Initial bolus amount 03: " + initialBolusValue03); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java index a4cdd49416..ce38e0ba28 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Get_Step_Bolus_Information.java @@ -7,17 +7,16 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Bolus_Get_Step_Bolus_Information extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Bolus_Get_Step_Bolus_Information() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_STEP_BOLUS_INFORMATION; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -58,7 +57,7 @@ public class DanaRS_Packet_Bolus_Get_Step_Bolus_Information extends DanaRS_Packe dataSize = 1; pump.bolusStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Result: " + error); log.debug("BolusType: " + bolusType); log.debug("Initial bolus amount: " + pump.initialBolusAmount + " U"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java index 7d9fe980e1..4f53ba9632 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java @@ -5,11 +5,10 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int extendedBolusOptionOnOff; private int bolusCalculationOption; @@ -77,7 +76,7 @@ public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet { this.missedBolus04EndHour = missedBolus04EndHour; this.missedBolus04EndMin = missedBolus04EndMin; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Setting bolus options"); } } @@ -114,7 +113,7 @@ public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java index 9a468457c9..23581d4d0c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java @@ -5,11 +5,10 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int cir01; private int cir02; @@ -47,7 +46,7 @@ public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet { this.cf05 = cf05; this.cf06 = cf06; this.cf07 = cf07; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -88,7 +87,7 @@ public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java index 079da8b688..8953ce020e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java @@ -5,11 +5,10 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private double amount; private double extendedAmount; @@ -26,7 +25,7 @@ public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet { this.extendedAmount = extendedAmount; this.extendedBolusDurationInHalfHours = extendedBolusDurationInHalfHours; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Dual bolus start : " + amount + " U extended: " + extendedAmount + " U halfhours: " + extendedBolusDurationInHalfHours); } @@ -47,7 +46,7 @@ public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java index 2d444ded1d..fb899b73d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java @@ -5,11 +5,10 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private double extendedAmount; private int extendedBolusDurationInHalfHours; @@ -24,7 +23,7 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet { this.extendedAmount = extendedAmount; this.extendedBolusDurationInHalfHours = extendedBolusDurationInHalfHours; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Extended bolus start : " + extendedAmount + " U halfhours: " + extendedBolusDurationInHalfHours); } @@ -42,7 +41,7 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java index d012c380e3..ab887c0fab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java @@ -5,24 +5,23 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS_CANCEL; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Cancel extended bolus"); } @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java index c30c803688..faaf505293 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java @@ -5,11 +5,10 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int bolusRate01; private int bolusRate02; @@ -27,7 +26,7 @@ public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet { this.bolusRate02 = (int) (bolusRate02 / 100d); this.bolusRate03 = (int) (bolusRate03 / 100d); this.bolusRate04 = (int) (bolusRate04 / 100d); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -48,7 +47,7 @@ public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java index 06be965ee3..2d423eb7ef 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java @@ -5,13 +5,12 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.interfaces.Constraint; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private double amount; private int speed; @@ -34,7 +33,7 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet { this.amount = amount; this.speed = speed; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Bolus start : " + amount + " speed: " + speed); } @@ -51,7 +50,7 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { errorCode = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (errorCode == 0) { log.debug("Result OK"); failed = false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java index f5f4736b21..eef9afe0e5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java @@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import com.cozmo.danar.util.BleCommandUtil; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private static Treatment t; private static Double amount; @@ -32,14 +31,14 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet { this.amount = amount; forced = false; stopped = false; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Stop bolus: amount: " + amount + " treatment: " + t.toString()); } @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java index 7f8c41fa8a..071ca66410 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Keep_Connection.java @@ -3,18 +3,17 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Etc_Keep_Connection extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Etc_Keep_Connection() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -23,7 +22,7 @@ public class DanaRS_Packet_Etc_Keep_Connection extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; int error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Result: " + error); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java index f09c81da2c..a7ace37421 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Etc_Set_History_Save.java @@ -3,13 +3,12 @@ package info.nightscout.androidaps.plugins.PumpDanaRS.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Etc_Set_History_Save extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int historyType; private int historyYear; @@ -37,7 +36,7 @@ public class DanaRS_Packet_Etc_Set_History_Save extends DanaRS_Packet { this.historySecond = historySecond; this.historyCode = historyCode; this.historyValue = historyValue; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -62,7 +61,7 @@ public class DanaRS_Packet_Etc_Set_History_Save extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; int error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Result: " + error); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java index 991f588de7..f505f9c619 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Delivery_Status.java @@ -5,16 +5,15 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_General_Delivery_Status extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_General_Delivery_Status() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DELIVERY_STATUS; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -23,7 +22,7 @@ public class DanaRS_Packet_General_Delivery_Status extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Status: " + status); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java index 9199264377..24bfc4b8a7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_More_Information.java @@ -7,17 +7,16 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_General_Get_More_Information extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_General_Get_More_Information() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -58,7 +57,7 @@ public class DanaRS_Packet_General_Get_More_Information extends DanaRS_Packet { dataSize = 2; pump.lastBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Daily total units: " + pump.dailyTotalUnits + " U"); log.debug("Is extended in progress: " + pump.isExtendedInProgress); log.debug("Extended bolus remaining minutes: " + pump.extendedBolusRemainingMinutes); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java index 9c23754a47..276653ff0f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Password.java @@ -5,17 +5,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_General_Get_Password extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_General_Get_Password() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PASSWORD; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -26,7 +25,7 @@ public class DanaRS_Packet_General_Get_Password extends DanaRS_Packet { int pass = ((data[DATA_START + 1] & 0x000000FF) << 8) + (data[DATA_START + 0] & 0x000000FF); pass = pass ^ 3463; pump.rs_password = Integer.toHexString(pass); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump password: " + pump.rs_password); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java index 0a893791c0..618ea29ed0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Pump_Check.java @@ -5,21 +5,20 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_General_Get_Pump_Check extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_General_Get_Pump_Check() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_CHECK; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -39,7 +38,7 @@ public class DanaRS_Packet_General_Get_Pump_Check extends DanaRS_Packet { dataSize = 1; pump.productCode = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Product Code: " + String.format("%02X ", pump.productCode)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java index 1e7668568a..fe7f9b40ed 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Shipping_Information.java @@ -5,17 +5,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_General_Get_Shipping_Information extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_General_Get_Shipping_Information() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -35,7 +34,7 @@ public class DanaRS_Packet_General_Get_Shipping_Information extends DanaRS_Packe dataSize = 3; pump.shippingCountry = asciiStringFromBuff(data, dataIndex, dataSize); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Serial number: " + pump.serialNumber); log.debug("Shipping date: " + pump.shippingDate); log.debug("Shipping country: " + pump.shippingCountry); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java index 3fded09f97..aa686aaa05 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_Today_Delivery_Total.java @@ -5,17 +5,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_General_Get_Today_Delivery_Total extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_General_Get_Today_Delivery_Total() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -35,7 +34,7 @@ public class DanaRS_Packet_General_Get_Today_Delivery_Total extends DanaRS_Packe dataSize = 2; pump.dailyTotalBolusUnits = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Daily total: " + pump.dailyTotalUnits + " U"); log.debug("Daily total bolus: " + pump.dailyTotalBolusUnits + " U"); log.debug("Daily total basal: " + pump.dailyTotalBasalUnits + " U"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java index e97e366ba4..156c5acc4f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Get_User_Time_Change_Flag.java @@ -5,16 +5,15 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_General_Get_User_Time_Change_Flag extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_General_Get_User_Time_Change_Flag() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_USER_TIME_CHANGE_FLAG; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -24,7 +23,7 @@ public class DanaRS_Packet_General_Get_User_Time_Change_Flag extends DanaRS_Pack int dataSize = 1; int userTimeChangeFlag = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("UserTimeChangeFlag: " + userTimeChangeFlag); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java index 195a3ce846..6b8f569c6d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Initial_Screen_Information.java @@ -5,18 +5,17 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_General_Initial_Screen_Information extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_General_Initial_Screen_Information() { super(); type = BleCommandUtil.DANAR_PACKET__TYPE_RESPONSE; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__INITIAL_SCREEN_INFORMATION; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -65,7 +64,7 @@ public class DanaRS_Packet_General_Initial_Screen_Information extends DanaRS_Pac dataSize = 2; pump.iob = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump suspended: " + pump.pumpSuspended); log.debug("Temp basal in progress: " + pump.isTempBasalInProgress); log.debug("Extended in progress: " + pump.isExtendedInProgress); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java index 1b5658ebcd..cd5a843336 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java @@ -5,11 +5,10 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int mode; @@ -21,7 +20,7 @@ public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet public DanaRS_Packet_General_Set_History_Upload_Mode(int mode) { this(); this.mode = mode; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message: mode: " + mode); } @@ -36,7 +35,7 @@ public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java index ebdcd4c976..07403d6908 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java @@ -5,23 +5,22 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (result == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java index c882e5afbb..70fece9864 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_.java @@ -7,16 +7,15 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.db.DanaRHistoryRecord; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; import info.nightscout.utils.DateUtil; public abstract class DanaRS_Packet_History_ extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int year = 0; private int month = 0; @@ -47,7 +46,7 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet { hour = cal.get(Calendar.HOUR_OF_DAY); min = cal.get(Calendar.MINUTE); sec = cal.get(Calendar.SECOND); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Loading event history from: " + new Date(cal.getTimeInMillis()).toLocaleString()); } @@ -72,7 +71,7 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet { int dataSize = 1; error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); done = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("History end. Code: " + error + " Success: " + (error == 0x00)); } else if (data.length == 5) { int dataIndex = DATA_START; @@ -83,7 +82,7 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet { dataIndex += dataSize; dataSize = 2; totalCount = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("History end. Code: " + error + " Success: " + (error == 0x00) + " Toatal count: " + totalCount); } else { int recordCode = byteArrayToInt(getBytes(data, DATA_START, 1)); @@ -106,7 +105,7 @@ public abstract class DanaRS_Packet_History_ extends DanaRS_Packet { int value = ((data[DATA_START + 8] & 0xFF) << 8) + (data[DATA_START + 9] & 0xFF); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("History packet: " + recordCode + " Date: " + datetimewihtsec.toLocaleString() + " Code: " + historyCode + " Value: " + value); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java index 7744e22ecd..541091954f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Alarm.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_History_Alarm extends DanaRS_Packet_History_ { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_History_Alarm() { super(); @@ -21,7 +20,7 @@ public class DanaRS_Packet_History_Alarm extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Alarm(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALARM; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java index 19ce9b6da0..1bf2bd302a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_All_History.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_History_All_History extends DanaRS_Packet_History_ { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_History_All_History() { super(); @@ -21,7 +20,7 @@ public class DanaRS_Packet_History_All_History extends DanaRS_Packet_History_ { public DanaRS_Packet_History_All_History(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java index a8797a49f9..917e3956f4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Basal.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_History_Basal extends DanaRS_Packet_History_ { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_History_Basal() { super(); @@ -21,7 +20,7 @@ public class DanaRS_Packet_History_Basal extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Basal(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BASAL; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java index 423f4345d3..176d92b1fb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Blood_Glucose.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_History_Blood_Glucose extends DanaRS_Packet_History_ { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_History_Blood_Glucose() { super(); @@ -21,7 +20,7 @@ public class DanaRS_Packet_History_Blood_Glucose extends DanaRS_Packet_History_ public DanaRS_Packet_History_Blood_Glucose(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java index 3f25c37ec0..e1b8ac1010 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Bolus.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_History_Bolus extends DanaRS_Packet_History_ { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_History_Bolus() { super(); @@ -21,7 +20,7 @@ public class DanaRS_Packet_History_Bolus extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Bolus(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java index 5cdec9f3e7..47a9b8fe11 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Carbohydrate.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_History_Carbohydrate extends DanaRS_Packet_History_ { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_History_Carbohydrate() { super(); @@ -21,7 +20,7 @@ public class DanaRS_Packet_History_Carbohydrate extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Carbohydrate(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java index 90b16d4ce5..12b7abc35b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Daily.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_History_Daily extends DanaRS_Packet_History_ { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_History_Daily() { super(); @@ -21,7 +20,7 @@ public class DanaRS_Packet_History_Daily extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Daily(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DAILY; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java index 98a3c13e6c..6a5de90813 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Prime.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_History_Prime extends DanaRS_Packet_History_ { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_History_Prime() { super(); @@ -21,7 +20,7 @@ public class DanaRS_Packet_History_Prime extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Prime(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__PRIME; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java index d5b138eba8..4566bb54b3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Refill.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_History_Refill extends DanaRS_Packet_History_ { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_History_Refill() { super(); @@ -21,7 +20,7 @@ public class DanaRS_Packet_History_Refill extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Refill(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java index 6c92a437fd..5d83f48a65 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Suspend.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_History_Suspend extends DanaRS_Packet_History_ { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_History_Suspend() { super(); @@ -21,7 +20,7 @@ public class DanaRS_Packet_History_Suspend extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Suspend(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SUSPEND; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java index 62aa5c274b..ce362574eb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_History_Temporary.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_History_Temporary extends DanaRS_Packet_History_ { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_History_Temporary() { super(); @@ -21,7 +20,7 @@ public class DanaRS_Packet_History_Temporary extends DanaRS_Packet_History_ { public DanaRS_Packet_History_Temporary(Date from) { super(from); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java index ba81fe1a77..58f362f1ad 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Alarm.java @@ -5,14 +5,13 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int alarmCode; @@ -20,7 +19,7 @@ public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet { super(); type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__ALARM; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -78,7 +77,7 @@ public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet { break; } - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Error detected: " + errorString); NSUpload.uploadError(errorString); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java index 86ff1d121e..836a52cb65 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Complete.java @@ -5,15 +5,14 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Treatments.Treatment; public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private static Treatment t; private static double amount; @@ -30,7 +29,7 @@ public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet { this.amount = amount; this.t = t; done = false; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message: amount: " + amount + " treatment: " + t.toString()); } @@ -48,7 +47,7 @@ public class DanaRS_Packet_Notify_Delivery_Complete extends DanaRS_Packet { MainApp.bus().post(bolusingEvent); } - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Delivered insulin: " + deliveredInsulin); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java index 96b98c8d80..30d7eeaf46 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Delivery_Rate_Display.java @@ -5,15 +5,14 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Treatments.Treatment; public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private static Treatment t; private static double amount; @@ -31,7 +30,7 @@ public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet { this.amount = amount; this.t = t; lastReceive = System.currentTimeMillis(); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message: amount: " + amount + " treatment: " + t.toString()); } @@ -49,7 +48,7 @@ public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet { MainApp.bus().post(bolusingEvent); } - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Delivered insulin so far: " + deliveredInsulin); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java index 7f2049af13..7110d8425c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Notify_Missed_Bolus_Alarm.java @@ -5,17 +5,16 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Notify_Missed_Bolus_Alarm extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Notify_Missed_Bolus_Alarm() { super(); type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__MISSED_BOLUS_ALARM; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -41,7 +40,7 @@ public class DanaRS_Packet_Notify_Missed_Bolus_Alarm extends DanaRS_Packet { dataIndex += dataSize; dataSize = 1; endMin = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Start hour: " + startHour); log.debug("Start min: " + startMin); log.debug("End hour: " + endHour); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java index 33c1722fc8..aacf859ef3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_Pump_Time.java @@ -7,17 +7,16 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Option_Get_Pump_Time extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Option_Get_Pump_Time() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_PUMP_TIME; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Requesting pump time"); } } @@ -51,7 +50,7 @@ public class DanaRS_Packet_Option_Get_Pump_Time extends DanaRS_Packet { Date time = new Date(100 + year, month - 1, day, hour, min, sec); DanaRPump.getInstance().pumpTime = time; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Pump time " + time.toLocaleString()); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java index 7a3d8a7093..4873775e86 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Get_User_Option.java @@ -5,18 +5,17 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Option_Get_User_Option extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Option_Get_User_Option() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Requesting user settings"); } } @@ -89,7 +88,7 @@ public class DanaRS_Packet_Option_Get_User_Option extends DanaRS_Packet { dataSize = 1; int selectableLanguage5 = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("timeDisplayType: " + pump.timeDisplayType); log.debug("buttonScrollOnOff: " + pump.buttonScrollOnOff); log.debug("beepAndAlarm: " + pump.beepAndAlarm); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java index ea90615c78..5f92036ef1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java @@ -7,11 +7,10 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private Date date; public int error; @@ -23,7 +22,7 @@ public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet { public DanaRS_Packet_Option_Set_Pump_Time(Date date) { this(); this.date = date; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Setting pump time " + date.toLocaleString()); } } @@ -45,7 +44,7 @@ public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (error == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java index 3709709fab..3e11aa93fa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java @@ -5,19 +5,18 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private int error; public DanaRS_Packet_Option_Set_User_Option() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_USER_OPTION; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Setting user settings"); } } @@ -25,7 +24,7 @@ public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet { @Override public byte[] getRequestParams() { DanaRPump pump = DanaRPump.getInstance(); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("UserOptions:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago" + "\ntimeDisplayType:" + pump.timeDisplayType + "\nbuttonScroll:" + pump.buttonScrollOnOff @@ -56,7 +55,7 @@ public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet { int dataIndex = DATA_START; int dataSize = 1; error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { if (error == 0) log.debug("Result OK"); else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java index d557d43853..6c43908309 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Review_Bolus_Avg.java @@ -5,16 +5,15 @@ import com.cozmo.danar.util.BleCommandUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; public class DanaRS_Packet_Review_Bolus_Avg extends DanaRS_Packet { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public DanaRS_Packet_Review_Bolus_Avg() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS_AVG; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -39,7 +38,7 @@ public class DanaRS_Packet_Review_Bolus_Avg extends DanaRS_Packet { dataIndex += dataSize; dataSize = 2; double bolusAvg28 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Bolus average 3d: " + bolusAvg03 + " U"); log.debug("Bolus average 7d: " + bolusAvg07 + " U"); log.debug("Bolus average 14d: " + bolusAvg14 + " U"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java index 7ba99a75ba..be241dbbfd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java @@ -22,11 +22,10 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.ScheduledFuture; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventPumpStatusChanged; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; @@ -44,7 +43,7 @@ import info.nightscout.utils.SP; */ public class BLEComm { - private Logger log = LoggerFactory.getLogger(Constants.PUMPBTCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPBTCOMM); private final long WRITE_DELAY_MILLIS = 50; @@ -85,7 +84,7 @@ public class BLEComm { } private boolean initialize() { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("Initializing BLEComm."); if (mBluetoothManager == null) { @@ -143,7 +142,7 @@ public class BLEComm { return false; } - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("Trying to create a new connection from: " + from); mBluetoothGatt = device.connectGatt(service.getApplicationContext(), false, mGattCallback); setCharacteristicNotification(getUARTReadBTGattChar(), true); @@ -156,7 +155,7 @@ public class BLEComm { } public synchronized void disconnect(String from) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("disconnect from: " + from); // cancel previous scheduled disconnection to prevent closing upcomming connection @@ -176,7 +175,7 @@ public class BLEComm { } public synchronized void close() { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("BluetoothAdapter close"); if (mBluetoothGatt == null) { return; @@ -197,7 +196,7 @@ public class BLEComm { } public void onServicesDiscovered(BluetoothGatt gatt, int status) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("onServicesDiscovered"); if (status == BluetoothGatt.GATT_SUCCESS) { findCharacteristic(); @@ -207,21 +206,21 @@ public class BLEComm { } public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("onCharacteristicRead" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); addToReadBuffer(characteristic.getValue()); readDataParsing(); } public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("onCharacteristicChanged" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); addToReadBuffer(characteristic.getValue()); new Thread(() -> readDataParsing()).start(); } public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("onCharacteristicWrite" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : "")); new Thread(() -> { synchronized (mSendQueue) { @@ -237,7 +236,7 @@ public class BLEComm { }; private synchronized void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enabled) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("setCharacteristicNotification"); if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { log.error("BluetoothAdapter not initialized_ERROR"); @@ -249,7 +248,7 @@ public class BLEComm { } public synchronized void readCharacteristic(BluetoothGattCharacteristic characteristic) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("readCharacteristic"); if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { log.error("BluetoothAdapter not initialized_ERROR"); @@ -273,7 +272,7 @@ public class BLEComm { characteristic.setValue(data); characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data)); mBluetoothGatt.writeCharacteristic(characteristic); }).start(); @@ -294,7 +293,7 @@ public class BLEComm { } private List getSupportedGattServices() { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("getSupportedGattServices"); if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { log.error("BluetoothAdapter not initialized_ERROR"); @@ -330,7 +329,7 @@ public class BLEComm { } private synchronized void onConnectionStateChangeSynchronized(BluetoothGatt gatt, int status, int newState) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("onConnectionStateChange"); if (newState == BluetoothProfile.STATE_CONNECTED) { @@ -340,7 +339,7 @@ public class BLEComm { isConnected = false; isConnecting = false; MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED)); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("Device was disconnected " + gatt.getDevice().getName());//Device was disconnected } } @@ -376,7 +375,7 @@ public class BLEComm { if ((readBuffer[idxStartByte] == PACKET_START_BYTE) && (readBuffer[idxStartByte + 1] == PACKET_START_BYTE)) { if (idxStartByte > 0) { // if buffer doesn't start with signature remove the leading trash - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("Shifting the input buffer by " + idxStartByte + " bytes"); System.arraycopy(readBuffer, idxStartByte, readBuffer, 0, bufferLength - idxStartByte); bufferLength -= idxStartByte; @@ -431,16 +430,16 @@ public class BLEComm { // 1st packet case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK: if (inputBuffer.length == 4 && inputBuffer[2] == 'O' && inputBuffer[3] == 'K') { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(inputBuffer)); // Grab pairing key from preferences if exists String pairingKey = SP.getString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, null); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("Using stored pairing key: " + pairingKey); if (pairingKey != null) { byte[] encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey); byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes)); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); } else { @@ -449,7 +448,7 @@ public class BLEComm { } } else if (inputBuffer.length == 6 && inputBuffer[2] == 'P' && inputBuffer[3] == 'U' && inputBuffer[4] == 'M' && inputBuffer[5] == 'P') { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(inputBuffer)); mSendQueue.clear(); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.pumperror))); @@ -457,13 +456,13 @@ public class BLEComm { Notification n = new Notification(Notification.PUMPERROR, MainApp.gs(R.string.pumperror), Notification.URGENT); MainApp.bus().post(new EventNewNotification(n)); } else if (inputBuffer.length == 6 && inputBuffer[2] == 'B' && inputBuffer[3] == 'U' && inputBuffer[4] == 'S' && inputBuffer[5] == 'Y') { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer)); mSendQueue.clear(); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.pumpbusy))); } else { // ERROR in response, wrong serial number - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer)); mSendQueue.clear(); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.connectionerror))); @@ -474,7 +473,7 @@ public class BLEComm { break; // 2nd packet, pairing key case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY: - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(inputBuffer)); if (inputBuffer[2] == (byte) 0x00) { // Paring is not requested, sending time info @@ -485,7 +484,7 @@ public class BLEComm { } break; case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST: - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(inputBuffer)); if (inputBuffer[2] != (byte) 0x00) { disconnect("passkey request failed"); @@ -493,7 +492,7 @@ public class BLEComm { break; // Paring response, OK button on pump pressed case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN: - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(inputBuffer)); // Paring is successfull, sending time info MainApp.bus().post(new EventDanaRSPairingSuccess()); @@ -501,24 +500,24 @@ public class BLEComm { byte[] pairingKey = {inputBuffer[2], inputBuffer[3]}; // store pairing key to preferences SP.putString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey)); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey)); break; // time and user password information. last packet in handshake case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION: - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */ DanaRS_Packet.toHexString(inputBuffer)); int size = inputBuffer.length; int pass = ((inputBuffer[size - 1] & 0x000000FF) << 8) + ((inputBuffer[size - 2] & 0x000000FF)); pass = pass ^ 3463; DanaRPump.getInstance().rs_password = Integer.toHexString(pass); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("Pump user password: " + Integer.toHexString(pass)); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED)); isConnected = true; isConnecting = false; - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("RS connected and status read"); break; } @@ -537,7 +536,7 @@ public class BLEComm { message = DanaRSMessageHashTable.findMessage(receivedCommand); } if (message != null) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(inputBuffer)); // process received data message.handleMessage(inputBuffer); @@ -575,7 +574,7 @@ public class BLEComm { byte[] command = {(byte) message.getType(), (byte) message.getOpCode()}; byte[] params = message.getRequestParams(); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(">>>>> " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params)); byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(message.getOpCode(), params, null); // If there is another message not completely sent, add to queue only @@ -656,7 +655,7 @@ public class BLEComm { MainApp.instance().startActivity(i); byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes)); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); } @@ -664,14 +663,14 @@ public class BLEComm { private void SendPumpCheck() { // 1st message sent to pump after connect byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, getConnectDeviceName()); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes)); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); } private void SendTimeInfo() { byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes)); writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java index 87d2b45c18..23618f2b18 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java @@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -24,6 +23,7 @@ import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventProfileSwitchChange; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity; @@ -83,7 +83,7 @@ import info.nightscout.utils.SP; import info.nightscout.utils.T; public class DanaRSService extends Service { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); private BLEComm bleComm = BLEComm.getInstance(this); @@ -156,11 +156,11 @@ public class DanaRSService extends Service { bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time()); long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Pump time difference: " + timeDiff + " seconds"); if (Math.abs(timeDiff) > 3) { if (Math.abs(timeDiff) > 60 * 60 * 1.5) { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Pump time difference: " + timeDiff + " seconds - large difference"); //If time-diff is very large, warn user until we can synchronize history readings properly Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); @@ -181,7 +181,7 @@ public class DanaRSService extends Service { bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date(DateUtil.now() + T.secs(10).msecs()))); bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time()); timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Pump time difference: " + timeDiff + " seconds"); } } @@ -206,7 +206,7 @@ public class DanaRSService extends Service { MainApp.bus().post(new EventInitializationChanged()); NSUpload.uploadDeviceStatus(); if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Approaching daily limit: " + danaRPump.dailyTotalUnits + "/" + danaRPump.maxDailyTotalUnits); if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT); @@ -218,7 +218,7 @@ public class DanaRSService extends Service { } catch (Exception e) { log.error("Unhandled exception", e); } - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Pump status loaded"); } @@ -235,11 +235,11 @@ public class DanaRSService extends Service { DanaRS_Packet_APS_History_Events msg; if (lastHistoryFetched == 0) { msg = new DanaRS_Packet_APS_History_Events(0); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Loading complete event history"); } else { msg = new DanaRS_Packet_APS_History_Events(lastHistoryFetched); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString()); } bleComm.sendMessage(msg); @@ -250,7 +250,7 @@ public class DanaRSService extends Service { lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - T.mins(1).msecs(); else lastHistoryFetched = 0; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Events loaded"); danaRPump.lastConnection = System.currentTimeMillis(); return new PumpEnactResult().success(true); @@ -298,7 +298,7 @@ public class DanaRSService extends Service { if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 20 sec expecting broken comm stop.stopped = true; stop.forced = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Communication stopped"); } } @@ -344,7 +344,7 @@ public class DanaRSService extends Service { } public void bolusStop() { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("bolusStop >>>>> @ " + (bolusingTreatment == null ? "" : bolusingTreatment.insulin)); DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(); stop.forced = true; @@ -521,11 +521,11 @@ public class DanaRSService extends Service { @Subscribe public void onStatusEvent(EventAppExit event) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("EventAppExit received"); stopSelf(); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("EventAppExit finished"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java index 49d945bdaa..1f1dc90eb1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java @@ -11,7 +11,6 @@ import android.support.v7.app.AlertDialog; import com.squareup.otto.Subscribe; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -21,6 +20,7 @@ import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.PumpDescription; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin; @@ -104,13 +104,13 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { private ServiceConnection mConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Service is disconnected"); sExecutionService = null; } public void onServiceConnected(ComponentName name, IBinder service) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Service is connected"); DanaRv2ExecutionService.LocalBinder mLocalBinder = (DanaRv2ExecutionService.LocalBinder) service; sExecutionService = mLocalBinder.getServiceInstance(); @@ -156,14 +156,14 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.invoke(); SP.putBoolean("allow_hardware_pump", true); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("First time HW pump allowed!"); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { pluginSwitcher.cancel(); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("User does not allow switching to HW pump!"); } }); @@ -215,7 +215,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode); else result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); // remove carbs because it's get from history seprately return result; @@ -259,7 +259,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { if (doTempOff) { // If temp in progress if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); return cancelTempBasal(false); } @@ -268,7 +268,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.percent = 100; result.isPercent = true; result.isTempCancel = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: doTempOff OK"); return result; } @@ -291,14 +291,14 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.duration = activeTemp.getPlannedRemainingMinutes(); result.isPercent = true; result.isTempCancel = false; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)"); return result; } } } // Convert duration from minutes to hours - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)"); if (percentRate == 0 && durationInMinutes > 30) { result = setTempBasalPercent(percentRate, durationInMinutes, profile, false); @@ -310,7 +310,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { log.error("setTempBasalAbsolute: Failed to set hightemp basal"); return result; } - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalAbsolute: hightemp basal set ok"); return result; } @@ -345,7 +345,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalPercent: Correct value already set"); return result; } @@ -364,7 +364,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setTempBasalPercent: OK"); return result; } @@ -386,7 +386,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.duration = pump.tempBasalRemainingMin; result.percent = pump.tempBasalPercent; result.isPercent = true; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("setHighTempBasalPercent: OK"); return result; } @@ -410,7 +410,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { result.success = true; result.isTempCancel = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("cancelRealTempBasal: OK"); return result; } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java index 49060192b5..61047a8d5a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java @@ -10,8 +10,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractSerialIOThread; @@ -22,7 +21,7 @@ import info.nightscout.utils.CRC; * Created by mike on 17.07.2016. */ public class SerialIOThread extends AbstractSerialIOThread { - private static Logger log = LoggerFactory.getLogger(Constants.PUMPBTCOMM); + private static Logger log = LoggerFactory.getLogger(L.PUMPBTCOMM); private InputStream mInputStream = null; private OutputStream mOutputStream = null; @@ -73,7 +72,7 @@ public class SerialIOThread extends AbstractSerialIOThread { message = MessageHashTable_v2.findMessage(command); } - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff)); // process the message content @@ -149,7 +148,7 @@ public class SerialIOThread extends AbstractSerialIOThread { processedMessage = message; byte[] messageBytes = message.getRawMessageBytes(); - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(">>>>> " + message.getMessageName() + " " + message.toHexString(messageBytes)); try { @@ -182,28 +181,28 @@ public class SerialIOThread extends AbstractSerialIOThread { try { mInputStream.close(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } try { mOutputStream.close(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } try { mRfCommSocket.close(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } try { System.runFinalization(); } catch (Exception e) { - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug(e.getMessage()); } - if (Config.logPumpBtComm) + if (L.isEnabled(L.PUMPBTCOMM)) log.debug("Disconnected: " + reason); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java index dcd2c5aace..8810edb815 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java @@ -3,12 +3,11 @@ package info.nightscout.androidaps.plugins.PumpDanaRv2.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; @@ -22,11 +21,11 @@ import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin; * Created by mike on 30.06.2016. */ public class MsgCheckValue_v2 extends MessageBase { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgCheckValue_v2() { SetCommand(0xF0F1); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -35,7 +34,7 @@ public class MsgCheckValue_v2 extends MessageBase { DanaRPump pump = DanaRPump.getInstance(); pump.isNewPump = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New firmware confirmed"); pump.model = intFromBuff(bytes, 0, 1); @@ -88,7 +87,7 @@ public class MsgCheckValue_v2 extends MessageBase { ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection return; } - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Product Code: " + String.format("%02X ", pump.productCode)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java index 2fe09d93bc..04eb6a1a78 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java @@ -6,8 +6,6 @@ import org.slf4j.LoggerFactory; import java.util.Date; import java.util.GregorianCalendar; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -15,6 +13,7 @@ import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.events.EventPumpStatusChanged; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; @@ -22,7 +21,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.utils.DateUtil; public class MsgHistoryEvents_v2 extends MessageBase { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public boolean done; public static long lastEventTimeLoaded = 0; @@ -33,7 +32,7 @@ public class MsgHistoryEvents_v2 extends MessageBase { gfrom.setTimeInMillis(from); AddParamDate(gfrom); done = false; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -45,7 +44,7 @@ public class MsgHistoryEvents_v2 extends MessageBase { AddParamByte((byte) 0); AddParamByte((byte) 0); done = false; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -75,11 +74,11 @@ public class MsgHistoryEvents_v2 extends MessageBase { DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime()); if (detailedBolusInfo == null) { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Detailed bolus info not found for " + datetime.toLocaleString()); detailedBolusInfo = new DetailedBolusInfo(); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Detailed bolus info found: " + detailedBolusInfo); } detailedBolusInfo.date = datetime.getTime(); @@ -90,7 +89,7 @@ public class MsgHistoryEvents_v2 extends MessageBase { switch (recordCode) { case DanaRPump.TEMPSTART: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); temporaryBasal.percentRate = param1; temporaryBasal.durationInMinutes = param2; @@ -98,13 +97,13 @@ public class MsgHistoryEvents_v2 extends MessageBase { status = "TEMPSTART " + DateUtil.timeString(datetime); break; case DanaRPump.TEMPSTOP: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal); status = "TEMPSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTART: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; @@ -112,7 +111,7 @@ public class MsgHistoryEvents_v2 extends MessageBase { status = "EXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTOP: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "EXTENDEDSTOP " + DateUtil.timeString(datetime); @@ -120,7 +119,7 @@ public class MsgHistoryEvents_v2 extends MessageBase { case DanaRPump.BOLUS: detailedBolusInfo.insulin = param1 / 100d; boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); status = "BOLUS " + DateUtil.timeString(datetime); @@ -128,13 +127,13 @@ public class MsgHistoryEvents_v2 extends MessageBase { case DanaRPump.DUALBOLUS: detailedBolusInfo.insulin = param1 / 100d; newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); status = "DUALBOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTART: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; @@ -142,33 +141,33 @@ public class MsgHistoryEvents_v2 extends MessageBase { status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTOP: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDON: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); status = "SUSPENDON " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDOFF: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); status = "SUSPENDOFF " + DateUtil.timeString(datetime); break; case DanaRPump.REFILL: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); status = "REFILL " + DateUtil.timeString(datetime); break; case DanaRPump.PRIME: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); status = "PRIME " + DateUtil.timeString(datetime); break; case DanaRPump.PROFILECHANGE: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); status = "PROFILECHANGE " + DateUtil.timeString(datetime); break; @@ -179,12 +178,12 @@ public class MsgHistoryEvents_v2 extends MessageBase { emptyCarbsInfo.source = Source.PUMP; emptyCarbsInfo.pumpId = datetime.getTime(); newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); status = "CARBS " + DateUtil.timeString(datetime); break; default: - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); status = "UNKNOWN " + DateUtil.timeString(datetime); break; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java index 428352d6a8..42964a64c6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java @@ -3,12 +3,11 @@ package info.nightscout.androidaps.plugins.PumpDanaRv2.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgSetAPSTempBasalStart_v2 extends MessageBase { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); protected final int PARAM30MIN = 160; protected final int PARAM15MIN = 150; @@ -20,7 +19,7 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase { public MsgSetAPSTempBasalStart_v2(int percent) { this(); setParams(percent); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message: percent: " + percent); } @@ -32,11 +31,11 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase { AddParamInt(percent); if (percent < 100) { AddParamByte((byte) PARAM30MIN); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("APS Temp basal start percent: " + percent + " duration 30 min"); } else { AddParamByte((byte) PARAM15MIN); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("APS Temp basal start percent: " + percent + " duration 15 min"); } } @@ -54,11 +53,11 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase { AddParamInt(percent); if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200% AddParamByte((byte) PARAM30MIN); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("APS Temp basal start percent: " + percent + " duration 30 min"); } else { AddParamByte((byte) PARAM15MIN); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("APS Temp basal start percent: " + percent + " duration 15 min"); } } @@ -67,11 +66,11 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set APS temp basal start result: " + result + " FAILED!!!"); } else { failed = false; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set APS temp basal start result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java index 4a044df0a0..0c55b29a3f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetHistoryEntry_v2.java @@ -6,12 +6,11 @@ import org.slf4j.LoggerFactory; import java.util.Date; import java.util.GregorianCalendar; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgSetHistoryEntry_v2 extends MessageBase { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgSetHistoryEntry_v2() { SetCommand(0xE004); @@ -26,7 +25,7 @@ public class MsgSetHistoryEntry_v2 extends MessageBase { AddParamDateTime(gtime); AddParamInt(param1); AddParamInt(param2); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set history entry: type: " + type + " date: " + new Date(time).toString() + " param1: " + param1 + " param2: " + param2); } @@ -35,10 +34,10 @@ public class MsgSetHistoryEntry_v2 extends MessageBase { int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set history entry result: " + result + " FAILED!!!"); } else { - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set history entry result: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java index 19827c484f..5d0238f2f7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusAPS_v2.java @@ -3,17 +3,16 @@ package info.nightscout.androidaps.plugins.PumpDanaRv2.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgStatusAPS_v2 extends MessageBase { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgStatusAPS_v2() { SetCommand(0xE001); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -24,7 +23,7 @@ public class MsgStatusAPS_v2 extends MessageBase { DanaRPump pump = DanaRPump.getInstance(); pump.iob = iob; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Delivered so far: " + deliveredSoFar); log.debug("Current pump IOB: " + iob); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java index 8ec4e991a7..c9a2446cd9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusBolusExtended_v2.java @@ -7,17 +7,16 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgStatusBolusExtended_v2 extends MessageBase { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgStatusBolusExtended_v2() { SetCommand(0x0207); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -46,7 +45,7 @@ public class MsgStatusBolusExtended_v2 extends MessageBase { pump.extendedBolusStart = extendedBolusStart; pump.extendedBolusRemainingMinutes = extendedBolusRemainingMinutes; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Is extended bolus running: " + isExtendedInProgress); log.debug("Extended bolus min: " + extendedBolusMinutes); log.debug("Extended bolus amount: " + extendedBolusAmount); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java index 2ece5ab47e..992b15e9ca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgStatusTempBasal_v2.java @@ -7,17 +7,16 @@ import org.slf4j.LoggerFactory; import java.util.Date; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; public class MsgStatusTempBasal_v2 extends MessageBase { - private Logger log = LoggerFactory.getLogger(Constants.PUMPCOMM); + private Logger log = LoggerFactory.getLogger(L.PUMPCOMM); public MsgStatusTempBasal_v2() { SetCommand(0x0205); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("New message"); } @@ -41,7 +40,7 @@ public class MsgStatusTempBasal_v2 extends MessageBase { pump.tempBasalTotalSec = tempBasalTotalSec; pump.tempBasalStart = tempBasalStart; - if (Config.logPumpComm) { + if (L.isEnabled(L.PUMPCOMM)) { log.debug("Is temp basal running: " + isTempBasalInProgress); log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress); log.debug("Current temp basal percent: " + tempBasalPercent); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java index 1b75e15246..4065d1624d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java @@ -11,7 +11,6 @@ import com.squareup.otto.Subscribe; import java.io.IOException; import java.util.Date; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -23,6 +22,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventProfileSwitchChange; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity; @@ -102,7 +102,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { @Subscribe public void onStatusEvent(EventAppExit event) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("EventAppExit received"); if (mSerialIOThread != null) @@ -111,7 +111,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { MainApp.instance().getApplicationContext().unregisterReceiver(receiver); stopSelf(); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("EventAppExit finished"); } @@ -205,11 +205,11 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime))); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Pump time difference: " + timeDiff + " seconds"); if (Math.abs(timeDiff) > 3) { if (Math.abs(timeDiff) > 60 * 60 * 1.5) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Pump time difference: " + timeDiff + " seconds - large difference"); //If time-diff is very large, warn user until we can synchronize history readings properly Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); @@ -230,7 +230,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { mSerialIOThread.sendMessage(new MsgSetTime(new Date(DateUtil.now() + T.secs(10).msecs()))); mSerialIOThread.sendMessage(new MsgSettingPumpTime()); timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Pump time difference: " + timeDiff + " seconds"); } } @@ -258,7 +258,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { MainApp.bus().post(new EventInitializationChanged()); NSUpload.uploadDeviceStatus(); if (mDanaRPump.dailyTotalUnits > mDanaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Approaching daily limit: " + mDanaRPump.dailyTotalUnits + "/" + mDanaRPump.maxDailyTotalUnits); if (System.currentTimeMillis() > lastApproachingDailyLimit + 30 * 60 * 1000) { Notification reportFail = new Notification(Notification.APPROACHING_DAILY_LIMIT, MainApp.gs(R.string.approachingdailylimit), Notification.URGENT); @@ -435,7 +435,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { } public void bolusStop() { - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("bolusStop >>>>> @ " + (mBolusingTreatment == null ? "" : mBolusingTreatment.insulin)); MsgBolusStop stop = new MsgBolusStop(); stop.forced = true; @@ -475,11 +475,11 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { MsgHistoryEvents_v2 msg; if (lastHistoryFetched == 0) { msg = new MsgHistoryEvents_v2(); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Loading complete event history"); } else { msg = new MsgHistoryEvents_v2(lastHistoryFetched); - if (Config.logPump) + if (L.isEnabled(L.PUMP)) log.debug("Loading event history from: " + new Date(lastHistoryFetched).toLocaleString()); } mSerialIOThread.sendMessage(msg); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java index 3d8863bd3e..661ed0b0a5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPlugin.java @@ -31,6 +31,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; @@ -460,7 +461,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai log.debug("Failure to deliver treatment"); } - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result); updateGui(); @@ -556,7 +557,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai .source(Source.USER); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal); updateGui(); - if (Config.logPumpComm) log.debug("Set temp basal " + percent + "% for " + durationInMinutes + "m"); + if (L.isEnabled(L.PUMPCOMM)) log.debug("Set temp basal " + percent + "% for " + durationInMinutes + "m"); connector.requestHistorySync(5000); connector.tryToGetPumpStatusAgain(); return new PumpEnactResult().success(true).enacted(true).percent(percent); @@ -574,7 +575,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai cancelExtendedBolus(); realTBRCancel(); updateGui(); - if (Config.logPumpComm) log.debug("Canceling temp basal"); + if (L.isEnabled(L.PUMPCOMM)) log.debug("Canceling temp basal"); connector.requestHistorySync(5000); connector.tryToGetPumpStatusAgain(); return new PumpEnactResult().success(true).enacted(true).isTempCancel(true); @@ -611,7 +612,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai updateGui(); connector.requestHistorySync(30000); connector.tryToGetPumpStatusAgain(); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Setting extended bolus: " + insulin + " mins:" + durationInMinutes); return new PumpEnactResult().success(true).enacted(true).duration(durationInMinutes).bolusDelivered(insulin); } catch (Exception e) { @@ -632,7 +633,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai exStop.source = Source.USER; TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(exStop); } - if (Config.logPumpComm) log.debug("Cancel extended bolus:"); + if (L.isEnabled(L.PUMPCOMM)) log.debug("Cancel extended bolus:"); if (bolusId != null) connector.requestHistorySync(5000); connector.tryToGetPumpStatusAgain(); updateGui(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java index fb41a72e88..209d24d193 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java @@ -8,7 +8,6 @@ import org.slf4j.LoggerFactory; import java.util.Date; import info.nightscout.androidaps.BuildConfig; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -19,6 +18,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.utils.DateUtil; @@ -149,7 +149,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface { PumpEnactResult result = new PumpEnactResult(); result.success = false; result.comment = MainApp.gs(R.string.pumperror); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Setting temp basal absolute: " + result); return result; } @@ -159,7 +159,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface { PumpEnactResult result = new PumpEnactResult(); result.success = false; result.comment = MainApp.gs(R.string.pumperror); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Settings temp basal percent: " + result); return result; } @@ -169,7 +169,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface { PumpEnactResult result = new PumpEnactResult(); result.success = false; result.comment = MainApp.gs(R.string.pumperror); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Setting extended bolus: " + result); return result; } @@ -179,7 +179,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface { PumpEnactResult result = new PumpEnactResult(); result.success = false; result.comment = MainApp.gs(R.string.pumperror); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Cancel temp basal: " + result); return result; } @@ -189,7 +189,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface { PumpEnactResult result = new PumpEnactResult(); result.success = false; result.comment = MainApp.gs(R.string.pumperror); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Canceling extended basal: " + result); return result; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java index 1586522791..7aae82b8f8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java @@ -24,6 +24,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; @@ -222,7 +223,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { bolusingEvent.percent = 100; MainApp.bus().post(bolusingEvent); SystemClock.sleep(1000); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result); MainApp.bus().post(new EventVirtualPumpUpdateGui()); lastDataTime = new Date(); @@ -250,7 +251,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { result.duration = durationInMinutes; result.comment = MainApp.gs(R.string.virtualpump_resultok); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Setting temp basal absolute: " + result); MainApp.bus().post(new EventVirtualPumpUpdateGui()); lastDataTime = new Date(); @@ -278,7 +279,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { result.duration = durationInMinutes; result.comment = MainApp.gs(R.string.virtualpump_resultok); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Settings temp basal percent: " + result); MainApp.bus().post(new EventVirtualPumpUpdateGui()); lastDataTime = new Date(); @@ -302,7 +303,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { result.duration = durationInMinutes; result.comment = MainApp.gs(R.string.virtualpump_resultok); TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Setting extended bolus: " + result); MainApp.bus().post(new EventVirtualPumpUpdateGui()); lastDataTime = new Date(); @@ -320,7 +321,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER); TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop); //tempBasal = null; - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Canceling temp basal: " + result); MainApp.bus().post(new EventVirtualPumpUpdateGui()); } @@ -340,7 +341,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { result.enacted = true; result.isTempCancel = true; result.comment = MainApp.gs(R.string.virtualpump_resultok); - if (Config.logPumpComm) + if (L.isEnabled(L.PUMPCOMM)) log.debug("Canceling extended basal: " + result); MainApp.bus().post(new EventVirtualPumpUpdateGui()); lastDataTime = new Date(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/AbstractSensitivityPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/AbstractSensitivityPlugin.java index 3e43b6a3d0..9f72f1b119 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/AbstractSensitivityPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/AbstractSensitivityPlugin.java @@ -3,12 +3,11 @@ package info.nightscout.androidaps.plugins.Sensitivity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.R; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.SensitivityInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.utils.Round; @@ -17,7 +16,7 @@ import info.nightscout.utils.SafeParse; public abstract class AbstractSensitivityPlugin extends PluginBase implements SensitivityInterface { - private static final Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); + private static final Logger log = LoggerFactory.getLogger(L.AUTOSENS); public AbstractSensitivityPlugin(PluginDescription pluginDescription) { super(pluginDescription); @@ -54,7 +53,7 @@ public abstract class AbstractSensitivityPlugin extends PluginBase implements Se if (ratio != rawRatio) { ratioLimit += "Ratio limited from " + rawRatio + " to " + ratio; - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(ratioLimit); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java index e5949e7298..350769ec24 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityAAPSPlugin.java @@ -10,14 +10,13 @@ import java.util.Arrays; import java.util.Date; import java.util.List; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; @@ -29,7 +28,7 @@ import info.nightscout.utils.SP; */ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { - private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); + private static Logger log = LoggerFactory.getLogger(L.AUTOSENS); static SensitivityAAPSPlugin plugin = null; @@ -63,18 +62,20 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { Profile profile = MainApp.getConfigBuilder().getProfile(); if (profile == null) { - log.debug("No profile"); + log.error("No profile"); return new AutosensResult(); } if (autosensDataTable == null || autosensDataTable.size() < 4) { - log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime()); return new AutosensResult(); } AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already if (current == null) { - log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); return new AutosensResult(); } @@ -132,7 +133,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { String ratioLimit = ""; String sensResult = ""; - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Records: " + index + " " + pastSensitivity); Arrays.sort(deviations); @@ -149,13 +150,13 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin { sensResult = "Sensitivity normal"; } - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(sensResult); AutosensResult output = fillResult(ratio, current.cob, pastSensitivity, ratioLimit, sensResult, deviationsArray.size()); - if (Config.logAutosensData) { + if (L.isEnabled(L.AUTOSENS)) { log.debug("Sensitivity to: {}, percentile: {} ratio: {} mealCOB: ", new Date(toTime).toLocaleString(), percentile, output.ratio, ratio, current.cob); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java index 142feba8da..2ddf402763 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref0Plugin.java @@ -10,14 +10,13 @@ import java.util.Arrays; import java.util.Date; import java.util.List; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; @@ -28,7 +27,7 @@ import info.nightscout.utils.DateUtil; */ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin { - private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); + private static Logger log = LoggerFactory.getLogger(L.AUTOSENS); static SensitivityOref0Plugin plugin = null; @@ -58,18 +57,20 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin { Profile profile = MainApp.getConfigBuilder().getProfile(); if (profile == null) { - log.debug("No profile"); + log.error("No profile"); return new AutosensResult(); } if (autosensDataTable == null || autosensDataTable.size() < 4) { - log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime()); return new AutosensResult(); } AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already if (current == null) { - log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); return new AutosensResult(); } @@ -127,14 +128,14 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin { String ratioLimit = ""; String sensResult = ""; - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Records: " + index + " " + pastSensitivity); Arrays.sort(deviations); for (double i = 0.9; i > 0.1; i = i - 0.02) { if (IobCobCalculatorPlugin.percentile(deviations, (i + 0.02)) >= 0 && IobCobCalculatorPlugin.percentile(deviations, i) < 0) { - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(Math.round(100 * i) + "% of non-meal deviations negative (target 45%-50%)"); } } @@ -153,7 +154,7 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin { sensResult = "Sensitivity normal"; } - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(sensResult); ratio = 1 + (basalOff / profile.getMaxDailyBasal()); @@ -161,7 +162,7 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin { AutosensResult output = fillResult(ratio, current.cob, pastSensitivity, ratioLimit, sensResult, deviationsArray.size()); - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Sensitivity to: {} ratio: {} mealCOB: {}", new Date(toTime).toLocaleString(), output.ratio, current.cob); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java index 4eb67cc69f..fe56899fea 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityOref1Plugin.java @@ -10,14 +10,13 @@ import java.util.Arrays; import java.util.Date; import java.util.List; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; @@ -28,7 +27,7 @@ import info.nightscout.utils.DateUtil; */ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { - private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); + private static Logger log = LoggerFactory.getLogger(L.AUTOSENS); static SensitivityOref1Plugin plugin = null; @@ -57,19 +56,21 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { Profile profile = MainApp.getConfigBuilder().getProfile(); if (profile == null) { - log.debug("No profile"); + log.error("No profile"); return new AutosensResult(); } if (autosensDataTable == null || autosensDataTable.size() < 4) { - log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime()); return new AutosensResult(); } // the current AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already if (current == null) { - log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); return new AutosensResult(); } @@ -121,11 +122,11 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { // when we have less than 8h worth of deviation data, add up to 90m of zero deviations // this dampens any large sensitivity changes detected based on too little data, without ignoring them completely - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Using most recent " + deviationsArray.size() + " deviations"); if (deviationsArray.size() < 96) { int pad = Math.round((1 - deviationsArray.size() / 96) * 18); - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Adding " + pad + " more zero deviations"); for (int d = 0; d < pad; d++) { //process.stderr.write("."); @@ -142,18 +143,18 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { String ratioLimit = ""; String sensResult = ""; - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Records: " + index + " " + pastSensitivity); Arrays.sort(deviations); for (double i = 0.9; i > 0.1; i = i - 0.01) { if (IobCobCalculatorPlugin.percentile(deviations, (i + 0.01)) >= 0 && IobCobCalculatorPlugin.percentile(deviations, i) < 0) { - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(Math.round(100 * i) + "% of non-meal deviations negative (>50% = sensitivity)"); } if (IobCobCalculatorPlugin.percentile(deviations, (i + 0.01)) > 0 && IobCobCalculatorPlugin.percentile(deviations, i) <= 0) { - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(Math.round(100 * i) + "% of non-meal deviations negative (>50% = resistance)"); } } @@ -172,7 +173,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { sensResult = "Sensitivity normal"; } - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(sensResult); ratio = 1 + (basalOff / profile.getMaxDailyBasal()); @@ -180,7 +181,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { AutosensResult output = fillResult(ratio, current.cob, pastSensitivity, ratioLimit, sensResult, deviationsArray.size()); - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Sensitivity to: {} ratio: {} mealCOB: {}", new Date(toTime).toLocaleString(), output.ratio, current.cob); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java index 0a98b19289..82c3d04d91 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Sensitivity/SensitivityWeightedAveragePlugin.java @@ -8,14 +8,13 @@ import org.slf4j.LoggerFactory; import java.util.Date; import java.util.List; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; @@ -27,7 +26,7 @@ import info.nightscout.utils.SP; */ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin { - private static Logger log = LoggerFactory.getLogger(Constants.AUTOSENS); + private static Logger log = LoggerFactory.getLogger(L.AUTOSENS); private static SensitivityWeightedAveragePlugin plugin = null; @@ -59,13 +58,14 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours); if (autosensDataTable == null || autosensDataTable.size() < 4) { - log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime()); + if (L.isEnabled(L.AUTOSENS)) + log.debug("No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime()); return new AutosensResult(); } AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already if (current == null) { - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); return new AutosensResult(); } @@ -73,7 +73,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin Profile profile = MainApp.getConfigBuilder().getProfile(); if (profile == null) { - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("No profile available"); return new AutosensResult(); } @@ -131,11 +131,11 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin } if (data.size() == 0) { - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime)); return new AutosensResult(); } else { - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime)); } @@ -160,7 +160,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin String ratioLimit = ""; String sensResult; - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Records: " + index + " " + pastSensitivity); double average = weightedsum / weights; @@ -175,13 +175,13 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin sensResult = "Sensitivity normal"; } - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug(sensResult); AutosensResult output = fillResult(ratio, current.cob, pastSensitivity, ratioLimit, sensResult, data.size()); - if (Config.logAutosensData) + if (L.isEnabled(L.AUTOSENS)) log.debug("Sensitivity to: {} weightedaverage: {} ratio: {} mealCOB: {}", new Date(toTime).toLocaleString(), average, output.ratio, current.cob); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java index b9f707a914..46d138c73d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceDexcomG5Plugin.java @@ -10,7 +10,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.db.BgReading; @@ -18,6 +17,7 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; import info.nightscout.utils.SP; @@ -26,7 +26,7 @@ import info.nightscout.utils.SP; */ public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterface { - private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE); + private static Logger log = LoggerFactory.getLogger(L.BGSOURCE); private static SourceDexcomG5Plugin plugin = null; @@ -65,12 +65,12 @@ public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterfac BgReading bgReading = new BgReading(); String data = bundle.getString("data"); - if (Config.logBgSource) + if (L.isEnabled(L.BGSOURCE)) log.debug("Received Dexcom Data", data); try { JSONArray jsonArray = new JSONArray(data); - if (Config.logBgSource) + if (L.isEnabled(L.BGSOURCE)) log.debug("Received Dexcom Data size:" + jsonArray.length()); for (int i = 0; i < jsonArray.length(); i++) { JSONObject json = jsonArray.getJSONObject(i); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java index 761457d296..07fdba51ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceGlimpPlugin.java @@ -6,8 +6,6 @@ import android.os.Bundle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.db.BgReading; @@ -15,13 +13,14 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; -import info.nightscout.utils.BundleLogger; +import info.nightscout.androidaps.logging.BundleLogger; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 05.08.2016. */ public class SourceGlimpPlugin extends PluginBase implements BgSourceInterface { - private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE); + private static Logger log = LoggerFactory.getLogger(L.BGSOURCE); private static SourceGlimpPlugin plugin = null; @@ -53,7 +52,7 @@ public class SourceGlimpPlugin extends PluginBase implements BgSourceInterface { Bundle bundle = intent.getExtras(); if (bundle == null) return; - if (Config.logBgSource) + if (L.isEnabled(L.BGSOURCE)) log.debug("Received Glimp Data: " + BundleLogger.log(bundle)); BgReading bgReading = new BgReading(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java index e96ea1b318..8bc6811ef4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceMM640gPlugin.java @@ -9,8 +9,6 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.db.BgReading; @@ -18,12 +16,13 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; /** * Created by mike on 05.08.2016. */ public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface { - private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE); + private static Logger log = LoggerFactory.getLogger(L.BGSOURCE); private static SourceMM640gPlugin plugin = null; @@ -60,7 +59,7 @@ public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface if (collection.equals("entries")) { final String data = bundle.getString("data"); - if (Config.logBgSource) + if (L.isEnabled(L.BGSOURCE)) log.debug("Received MM640g Data: ", data); if ((data != null) && (data.length() > 0)) { @@ -81,7 +80,7 @@ public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface MainApp.getDbHelper().createIfNotExists(bgReading, "MM640g"); break; default: - if (Config.logBgSource) + if (L.isEnabled(L.BGSOURCE)) log.debug("Unknown entries type: " + type); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java index 89408d3e46..eb901ca1b7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java @@ -9,7 +9,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.db.BgReading; @@ -17,6 +16,7 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv; import info.nightscout.utils.JsonHelper; @@ -26,7 +26,7 @@ import info.nightscout.utils.SP; * Created by mike on 05.08.2016. */ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterface { - private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE); + private static Logger log = LoggerFactory.getLogger(L.BGSOURCE); private static SourceNSClientPlugin plugin = null; @@ -66,7 +66,7 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac try { if (bundles.containsKey("sgv")) { String sgvstring = bundles.getString("sgv"); - if (Config.logBgSource) + if (L.isEnabled(L.BGSOURCE)) log.debug("Received NS Data: " + sgvstring); JSONObject sgvJson = new JSONObject(sgvstring); @@ -75,7 +75,7 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac if (bundles.containsKey("sgvs")) { String sgvstring = bundles.getString("sgvs"); - if (Config.logBgSource) + if (L.isEnabled(L.BGSOURCE)) log.debug("Received NS Data: " + sgvstring); JSONArray jsonArray = new JSONArray(sgvstring); for (int i = 0; i < jsonArray.length(); i++) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java index 321c1b5394..4cdd8dd810 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourcePoctechPlugin.java @@ -18,6 +18,7 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.utils.JsonHelper; import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload; import info.nightscout.utils.SP; @@ -26,7 +27,7 @@ import info.nightscout.utils.SP; * Created by mike on 05.08.2016. */ public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface { - private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE); + private static Logger log = LoggerFactory.getLogger(L.BGSOURCE); private static SourcePoctechPlugin plugin = null; @@ -63,12 +64,12 @@ public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface BgReading bgReading = new BgReading(); String data = bundle.getString("data"); - if (Config.logBgSource) + if (L.isEnabled(L.BGSOURCE)) log.debug("Received Poctech Data", data); try { JSONArray jsonArray = new JSONArray(data); - if (Config.logBgSource) + if (L.isEnabled(L.BGSOURCE)) log.debug("Received Poctech Data size:" + jsonArray.length()); for (int i = 0; i < jsonArray.length(); i++) { JSONObject json = jsonArray.getJSONObject(i); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java index 3498b115f4..eeffa87324 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java @@ -6,23 +6,22 @@ import android.os.Bundle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.interfaces.BgSourceInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; -import info.nightscout.utils.BundleLogger; +import info.nightscout.androidaps.logging.BundleLogger; /** * Created by mike on 05.08.2016. */ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface { - private static Logger log = LoggerFactory.getLogger(Constants.BGSOURCE); + private static Logger log = LoggerFactory.getLogger(L.BGSOURCE); private static SourceXdripPlugin plugin = null; @@ -56,7 +55,7 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface { Bundle bundle = intent.getExtras(); if (bundle == null) return; - if (Config.logBgSource) + if (L.isEnabled(L.BGSOURCE)) log.debug("Received xDrip data: " + BundleLogger.log(intent.getExtras())); BgReading bgReading = new BgReading(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentService.java index b219522102..ab2e6b4e87 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentService.java @@ -29,8 +29,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.ICallback; @@ -39,6 +37,7 @@ import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.EventNsTreatment; import info.nightscout.androidaps.events.EventReloadTreatmentData; import info.nightscout.androidaps.events.EventTreatmentChange; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData; import info.nightscout.utils.JsonHelper; @@ -48,7 +47,7 @@ import info.nightscout.utils.JsonHelper; */ public class TreatmentService extends OrmLiteBaseService { - private static Logger log = LoggerFactory.getLogger(Constants.DATATREATMENTS); + private static Logger log = LoggerFactory.getLogger(L.DATATREATMENTS); private static final ScheduledExecutorService treatmentEventWorker = Executors.newSingleThreadScheduledExecutor(); private static ScheduledFuture scheduledTreatmentEventPost = null; @@ -104,7 +103,7 @@ public class TreatmentService extends OrmLiteBaseService { public void onCreate() { super.onCreate(); try { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.info("onCreate"); TableUtils.createTableIfNotExists(this.getConnectionSource(), Treatment.class); } catch (SQLException e) { @@ -124,7 +123,7 @@ public class TreatmentService extends OrmLiteBaseService { throw new RuntimeException(e); } } else { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.info("onUpgrade"); // this.resetFood(); } @@ -165,11 +164,11 @@ public class TreatmentService extends OrmLiteBaseService { class PostRunnable implements Runnable { public void run() { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("Firing EventReloadTreatmentData"); MainApp.bus().post(event); if (DatabaseHelper.earliestDataChange != null) { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("Firing EventNewHistoryData"); MainApp.bus().post(new EventNewHistoryData(DatabaseHelper.earliestDataChange)); } @@ -262,7 +261,7 @@ public class TreatmentService extends OrmLiteBaseService { boolean sameSource = existingTreatment.source == treatment.source; if (!equalRePumpHistory) { // another treatment exists. Update it with the treatment coming from the pump - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("Pump record already found in database: " + existingTreatment.toString() + " wanting to add " + treatment.toString()); long oldDate = existingTreatment.date; @@ -287,7 +286,7 @@ public class TreatmentService extends OrmLiteBaseService { boolean equalRePumpHistory = existingTreatment.equalsRePumpHistory(treatment); boolean sameSource = existingTreatment.source == treatment.source; long oldDate = existingTreatment.date; - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("Pump record already found in database: " + existingTreatment.toString() + " wanting to add " + treatment.toString()); //preserve carbs @@ -304,7 +303,7 @@ public class TreatmentService extends OrmLiteBaseService { return new UpdateReturn(equalRePumpHistory || sameSource, false); } getDao().create(treatment); - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString()); DatabaseHelper.updateEarliestDataChange(treatment.date); scheduleTreatmentChange(treatment); @@ -319,7 +318,7 @@ public class TreatmentService extends OrmLiteBaseService { getDao().delete(old); // need to delete/create because date may change too old.copyFrom(treatment); getDao().create(old); - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("Updating record by date from: " + Source.getString(treatment.source) + " " + old.toString()); if (historyChange) { DatabaseHelper.updateEarliestDataChange(oldDate); @@ -340,7 +339,7 @@ public class TreatmentService extends OrmLiteBaseService { getDao().delete(old); // need to delete/create because date may change too old.copyFrom(treatment); getDao().create(old); - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("Updating record by _id from: " + Source.getString(treatment.source) + " " + old.toString()); if (historyChange) { DatabaseHelper.updateEarliestDataChange(oldDate); @@ -352,7 +351,7 @@ public class TreatmentService extends OrmLiteBaseService { } } getDao().create(treatment); - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString()); DatabaseHelper.updateEarliestDataChange(treatment.date); scheduleTreatmentChange(treatment); @@ -360,7 +359,7 @@ public class TreatmentService extends OrmLiteBaseService { } if (treatment.source == Source.USER) { getDao().create(treatment); - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString()); DatabaseHelper.updateEarliestDataChange(treatment.date); scheduleTreatmentChange(treatment); @@ -413,7 +412,7 @@ public class TreatmentService extends OrmLiteBaseService { private void deleteByNSId(String _id) { Treatment stored = findByNSId(_id); if (stored != null) { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("Removing Treatment record from database: " + stored.toString()); delete(stored); DatabaseHelper.updateEarliestDataChange(stored.date); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java index dca46916f5..5c952b58f1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; @@ -38,6 +37,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.TreatmentsInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; @@ -56,7 +56,7 @@ import info.nightscout.utils.T; * Created by mike on 05.08.2016. */ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface { - private Logger log = LoggerFactory.getLogger(Constants.DATATREATMENTS); + private Logger log = LoggerFactory.getLogger(L.DATATREATMENTS); private static TreatmentsPlugin treatmentsPlugin; @@ -110,7 +110,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface } private void initializeTreatmentData() { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("initializeTreatmentData"); double dia = Constants.defaultDIA; if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null) @@ -123,7 +123,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface } private void initializeTempBasalData() { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("initializeTempBasalData"); double dia = Constants.defaultDIA; if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null) @@ -137,7 +137,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface } private void initializeExtendedBolusData() { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("initializeExtendedBolusData"); double dia = Constants.defaultDIA; if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null) @@ -151,7 +151,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface } private void initializeTempTargetData() { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("initializeTempTargetData"); synchronized (tempTargets) { long fromMills = System.currentTimeMillis() - 60 * 60 * 1000L * 24; @@ -160,7 +160,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface } private void initializeProfileSwitchData() { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("initializeProfileSwitchData"); synchronized (profiles) { profiles.reset().add(MainApp.getDbHelper().getProfileSwitchData(false)); @@ -305,7 +305,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface last = t.date; } } - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("Last bolus time: " + new Date(last).toLocaleString()); return last; } @@ -334,7 +334,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface @Subscribe public void onStatusEvent(final EventReloadTreatmentData ev) { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("EventReloadTreatmentData"); initializeTreatmentData(); initializeExtendedBolusData(); @@ -345,7 +345,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface @Subscribe @SuppressWarnings("unused") public void onStatusEvent(final EventReloadTempBasalData ev) { - if (Config.logDataTreatments) + if (L.isEnabled(L.DATATREATMENTS)) log.debug("EventReloadTempBasalData"); initializeTempBasalData(); updateTotalIOBTempBasals(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java index 96f550128d..4df1e65c2c 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java @@ -12,8 +12,6 @@ import org.slf4j.LoggerFactory; import java.util.LinkedList; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -22,6 +20,7 @@ import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.events.EventBolusRequested; import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressHelperActivity; @@ -77,7 +76,7 @@ import info.nightscout.androidaps.queue.commands.CommandTempBasalPercent; */ public class CommandQueue { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); private final LinkedList queue = new LinkedList<>(); Command performing; @@ -111,13 +110,13 @@ public class CommandQueue { private synchronized void inject(Command command) { // inject as a first command - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Adding as first: " + command.getClass().getSimpleName() + " - " + command.status()); queue.addFirst(command); } private synchronized void add(Command command) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Adding: " + command.getClass().getSimpleName() + " - " + command.status()); queue.add(command); } @@ -151,17 +150,17 @@ public class CommandQueue { // start thread again if not already running protected synchronized void notifyAboutNewCommand() { while (thread != null && thread.getState() != Thread.State.TERMINATED && thread.waitingForDisconnect) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Waiting for previous thread finish"); SystemClock.sleep(500); } if (thread == null || thread.getState() == Thread.State.TERMINATED) { thread = new QueueThread(this); thread.start(); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Starting new thread"); } else { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Thread is already running"); } } @@ -187,12 +186,12 @@ public class CommandQueue { if (type == Command.CommandType.SMB_BOLUS) { if (isRunning(Command.CommandType.BOLUS) || bolusInQueue()) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Rejecting SMB since a bolus is queue/running"); return false; } if (detailedBolusInfo.lastKnownBolusTime < TreatmentsPlugin.getPlugin().getLastBolusTime()) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Rejecting bolus, another bolus was issued since request time"); return false; } @@ -346,7 +345,7 @@ public class CommandQueue { // returns true if command is queued public boolean setProfile(Profile profile, Callback callback) { if (isThisProfileSet(profile)) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Correct profile already set"); if (callback != null) callback.result(new PumpEnactResult().success(true).enacted(false)).run(); @@ -391,7 +390,7 @@ public class CommandQueue { // returns true if command is queued public boolean readStatus(String reason, Callback callback) { if (isLastScheduled(Command.CommandType.READSTATUS)) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("READSTATUS " + reason + " ignored as duplicated"); if (callback != null) callback.result(executingNowError()).run(); @@ -507,7 +506,7 @@ public class CommandQueue { if (activePump != null && current != null) { boolean result = activePump.isThisProfileSet(profile); if (!result) { - if (Config.logQueue) { + if (L.isEnabled(L.PUMPQUEUE)) { log.debug("Current profile: " + current.toString()); log.debug("New profile: " + profile.toString()); } diff --git a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java index 252c537b9b..83414b23fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java @@ -8,12 +8,12 @@ import android.os.SystemClock; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning; import info.nightscout.androidaps.queue.events.EventQueueChanged; @@ -24,7 +24,7 @@ import info.nightscout.utils.SP; */ public class QueueThread extends Thread { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); private CommandQueue queue; @@ -52,7 +52,7 @@ public class QueueThread extends Thread { while (true) { PumpInterface pump = ConfigBuilderPlugin.getActivePump(); if (pump == null) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("pump == null"); MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.pumpNotInitialized))); SystemClock.sleep(1000); @@ -63,7 +63,7 @@ public class QueueThread extends Thread { if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) { MainApp.bus().post(new EventDismissBolusprogressIfRunning(null)); MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.connectiontimedout))); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("timed out"); pump.stopConnecting(); @@ -72,7 +72,7 @@ public class QueueThread extends Thread { long last_watchdog = SP.getLong(R.string.key_btwatchdog_lastbark, 0l); watchdog = watchdog && System.currentTimeMillis() - last_watchdog > (Constants.MIN_WATCHDOG_INTERVAL_IN_SECONDS * 1000); if (watchdog) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("BT watchdog - toggeling the phonest bluetooth"); //write time SP.putLong(R.string.key_btwatchdog_lastbark, System.currentTimeMillis()); @@ -92,7 +92,7 @@ public class QueueThread extends Thread { pump.connect("watchdog"); } else { queue.clear(); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("no connection possible"); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING)); pump.disconnect("Queue empty"); @@ -102,7 +102,7 @@ public class QueueThread extends Thread { } if (pump.isConnecting()) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("connecting " + secondsElapsed); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed)); SystemClock.sleep(1000); @@ -111,7 +111,7 @@ public class QueueThread extends Thread { if (!pump.isConnected()) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("connect"); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed)); pump.connect("Connection needed"); @@ -122,13 +122,13 @@ public class QueueThread extends Thread { if (queue.performing() == null) { if (!connectLogged) { connectLogged = true; - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("connection time " + secondsElapsed + "s"); } // Pickup 1st command and set performing variable if (queue.size() > 0) { queue.pickup(); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("performing " + queue.performing().status()); MainApp.bus().post(new EventQueueChanged()); queue.performing().execute(); @@ -144,16 +144,16 @@ public class QueueThread extends Thread { long secondsFromLastCommand = (System.currentTimeMillis() - lastCommandTime) / 1000; if (secondsFromLastCommand >= 5) { waitingForDisconnect = true; - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("queue empty. disconnect"); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING)); pump.disconnect("Queue empty"); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED)); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("disconnected"); return; } else { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("waiting for disconnect"); SystemClock.sleep(1000); } diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java index e21fb3f276..7207f5b8d1 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/Command.java @@ -3,18 +3,17 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.queue.Callback; /** * Created by mike on 09.11.2017. */ public abstract class Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); public enum CommandType { BOLUS, @@ -40,7 +39,7 @@ public abstract class Command { PumpEnactResult result = new PumpEnactResult(); result.success = false; result.comment = MainApp.gs(R.string.connectiontimedout); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result cancel"); if (callback != null) callback.result(result).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java index 89ebfb88b4..7e17e831e9 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java @@ -3,11 +3,10 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog; import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning; @@ -19,7 +18,7 @@ import info.nightscout.utils.DecimalFormatter; */ public class CommandBolus extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); private DetailedBolusInfo detailedBolusInfo; @@ -35,7 +34,7 @@ public class CommandBolus extends Command { BolusProgressDialog.bolusEnded = true; MainApp.bus().post(new EventDismissBolusprogressIfRunning(r)); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted); if (callback != null) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java index 5874e56585..164a049647 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java @@ -3,9 +3,8 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.queue.Callback; @@ -14,7 +13,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandCancelExtendedBolus extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); public CommandCancelExtendedBolus(Callback callback) { commandType = CommandType.EXTENDEDBOLUS; @@ -24,7 +23,7 @@ public class CommandCancelExtendedBolus extends Command { @Override public void execute() { PumpEnactResult r = ConfigBuilderPlugin.getActivePump().cancelExtendedBolus(); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted); if (callback != null) callback.result(r).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java index 0394e3a40a..5daa0e38e4 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java @@ -3,9 +3,8 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.queue.Callback; @@ -14,7 +13,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandCancelTempBasal extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); private boolean enforceNew; @@ -27,7 +26,7 @@ public class CommandCancelTempBasal extends Command { @Override public void execute() { PumpEnactResult r = ConfigBuilderPlugin.getActivePump().cancelTempBasal(enforceNew); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted); if (callback != null) callback.result(r).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java index 25c73f24f5..ea329c04d7 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java @@ -3,9 +3,8 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.queue.Callback; @@ -14,7 +13,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandExtendedBolus extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); private double insulin; private int durationInMinutes; @@ -29,7 +28,7 @@ public class CommandExtendedBolus extends Command { @Override public void execute() { PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setExtendedBolus(insulin, durationInMinutes); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result rate: " + insulin + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted); if (callback != null) callback.result(r).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java index 6a0abe712b..5cc954f5ff 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java @@ -3,11 +3,10 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.interfaces.DanaRInterface; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.queue.Callback; @@ -16,7 +15,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandLoadEvents extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); public CommandLoadEvents(Callback callback) { commandType = CommandType.LOADEVENTS; @@ -29,7 +28,7 @@ public class CommandLoadEvents extends Command { if (pump instanceof DanaRInterface) { DanaRInterface danaPump = (DanaRInterface) pump; PumpEnactResult r = danaPump.loadEvents(); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted); if (callback != null) callback.result(r).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java index 0dcff6bffe..1259812676 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java @@ -3,11 +3,10 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.interfaces.DanaRInterface; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.queue.Callback; @@ -16,7 +15,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandLoadHistory extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); private byte type; @@ -32,7 +31,7 @@ public class CommandLoadHistory extends Command { if (pump instanceof DanaRInterface) { DanaRInterface danaPump = (DanaRInterface) pump; PumpEnactResult r = danaPump.loadHistory(type); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted); if (callback != null) callback.result(r).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java index 0c419c332e..1212303e82 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java @@ -3,10 +3,9 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.queue.Callback; @@ -15,7 +14,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandLoadTDDs extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); public CommandLoadTDDs(Callback callback) { @@ -27,7 +26,7 @@ public class CommandLoadTDDs extends Command { public void execute() { PumpInterface pump = ConfigBuilderPlugin.getActivePump(); PumpEnactResult r = pump.loadTDDs(); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted); if (callback != null) callback.result(r).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java index 3e4ccd58f3..b014b66969 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java @@ -3,8 +3,7 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.queue.Callback; import info.nightscout.utils.LocalAlertUtils; @@ -14,7 +13,7 @@ import info.nightscout.utils.LocalAlertUtils; */ public class CommandReadStatus extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); private String reason; @@ -28,7 +27,7 @@ public class CommandReadStatus extends Command { public void execute() { ConfigBuilderPlugin.getActivePump().getPumpStatus(); LocalAlertUtils.notifyPumpStatusRead(); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("CommandReadStatus executed. Reason: " + reason); if (callback != null) callback.result(null).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java index 2cadda3a44..affc7aed22 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java @@ -3,10 +3,9 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.queue.Callback; @@ -19,7 +18,7 @@ import info.nightscout.utils.T; */ public class CommandSMBBolus extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); private DetailedBolusInfo detailedBolusInfo; @@ -34,18 +33,18 @@ public class CommandSMBBolus extends Command { PumpEnactResult r; long lastBolusTime = TreatmentsPlugin.getPlugin().getLastBolusTime(); if (lastBolusTime != 0 && lastBolusTime + T.mins(3).msecs() > DateUtil.now()) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("SMB requsted but still in 3 min interval"); r = new PumpEnactResult().enacted(false).success(false).comment("SMB requsted but still in 3 min interval"); } else if (detailedBolusInfo.deliverAt != 0 && detailedBolusInfo.deliverAt + T.mins(1).msecs() > System.currentTimeMillis()) { r = ConfigBuilderPlugin.getActivePump().deliverTreatment(detailedBolusInfo); } else { r = new PumpEnactResult().enacted(false).success(false).comment("SMB request too old"); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("SMB bolus canceled. delivetAt: " + DateUtil.dateAndTimeString(detailedBolusInfo.deliverAt)); } - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted); if (callback != null) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java index 20c406e59e..b62ef576d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java @@ -3,8 +3,6 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; @@ -12,6 +10,7 @@ import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; @@ -22,7 +21,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandSetProfile extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); private Profile profile; @@ -35,7 +34,7 @@ public class CommandSetProfile extends Command { @Override public void execute() { if (ConfigBuilderPlugin.getCommandQueue().isThisProfileSet(profile)) { - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Correct profile already set. profile: " + profile.toString()); if (callback != null) callback.result(new PumpEnactResult().success(true).enacted(false)).run(); @@ -43,7 +42,7 @@ public class CommandSetProfile extends Command { } PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setNewBasalProfile(profile); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted + " profile: " + profile.toString()); if (callback != null) callback.result(r).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java index af358604bc..8a9ae21c70 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java @@ -3,11 +3,10 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.interfaces.DanaRInterface; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.queue.Callback; @@ -16,7 +15,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandSetUserSettings extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); public CommandSetUserSettings(Callback callback) { commandType = CommandType.SETUSERSETTINGS; @@ -29,7 +28,7 @@ public class CommandSetUserSettings extends Command { if (pump instanceof DanaRInterface) { DanaRInterface danaPump = (DanaRInterface) pump; PumpEnactResult r = danaPump.setUserOptions(); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted); if (callback != null) callback.result(r).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java index 1ed0737bc0..a2787cabb6 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java @@ -3,10 +3,9 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.queue.Callback; @@ -15,7 +14,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandTempBasalAbsolute extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); private int durationInMinutes; private double absoluteRate; @@ -34,7 +33,7 @@ public class CommandTempBasalAbsolute extends Command { @Override public void execute() { PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalAbsolute(absoluteRate, durationInMinutes, profile, enforceNew); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result rate: " + absoluteRate + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted); if (callback != null) callback.result(r).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java index 8aaaf91d52..efdfca0a69 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java @@ -3,10 +3,9 @@ package info.nightscout.androidaps.queue.commands; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.queue.Callback; @@ -15,7 +14,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandTempBasalPercent extends Command { - private Logger log = LoggerFactory.getLogger(Constants.PUMPQUEUE); + private Logger log = LoggerFactory.getLogger(L.PUMPQUEUE); private int durationInMinutes; private int percent; @@ -34,7 +33,7 @@ public class CommandTempBasalPercent extends Command { @Override public void execute() { PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalPercent(percent, durationInMinutes, profile, enforceNew); - if (Config.logQueue) + if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result percent: " + percent + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted); if (callback != null) callback.result(r).run(); diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.java index 535f64c85f..087cd3a5f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.java @@ -7,16 +7,15 @@ import android.support.v4.content.WakefulBroadcastReceiver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Constants; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.services.DataService; -import info.nightscout.androidaps.Config; public class DataReceiver extends WakefulBroadcastReceiver { - private static Logger log = LoggerFactory.getLogger(Constants.DATASERVICE); + private static Logger log = LoggerFactory.getLogger(L.DATASERVICE); @Override public void onReceive(Context context, Intent intent) { - if (Config.logDataService) + if (L.isEnabled(L.DATASERVICE)) log.debug("onReceive " + intent); startWakefulService(context, new Intent(context, DataService.class) .setAction(intent.getAction()) diff --git a/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.java b/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.java index d4cfca9c59..43fbae83eb 100644 --- a/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.java +++ b/app/src/main/java/info/nightscout/androidaps/services/AlarmSoundService.java @@ -13,13 +13,12 @@ import org.slf4j.LoggerFactory; import java.io.IOException; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.logging.L; public class AlarmSoundService extends Service { - private static Logger log = LoggerFactory.getLogger(Constants.ALARM); + private static Logger log = LoggerFactory.getLogger(L.ALARM); MediaPlayer player; int resourceId = R.raw.error; @@ -36,14 +35,14 @@ public class AlarmSoundService extends Service { @Override public void onCreate() { super.onCreate(); - if (Config.logAlarm) + if (L.isEnabled(L.ALARM)) log.debug("onCreate"); } public int onStartCommand(Intent intent, int flags, int startId) { if (player != null && player.isPlaying()) player.stop(); - if (Config.logAlarm) + if (L.isEnabled(L.ALARM)) log.debug("onStartCommand"); if (intent != null && intent.hasExtra("soundid")) resourceId = intent.getIntExtra("soundid", R.raw.error); @@ -78,7 +77,7 @@ public class AlarmSoundService extends Service { public void onDestroy() { player.stop(); player.release(); - if (Config.logAlarm) + if (L.isEnabled(L.ALARM)) log.debug("onDestroy"); } } diff --git a/app/src/main/java/info/nightscout/androidaps/services/DataService.java b/app/src/main/java/info/nightscout/androidaps/services/DataService.java index 95b3e70195..c0cfe07370 100644 --- a/app/src/main/java/info/nightscout/androidaps/services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/services/DataService.java @@ -11,13 +11,12 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.events.EventNsFood; import info.nightscout.androidaps.events.EventNsTreatment; +import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSMbg; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus; @@ -33,13 +32,13 @@ import info.nightscout.androidaps.plugins.Source.SourceNSClientPlugin; import info.nightscout.androidaps.plugins.Source.SourcePoctechPlugin; import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin; import info.nightscout.androidaps.receivers.DataReceiver; -import info.nightscout.utils.BundleLogger; +import info.nightscout.androidaps.logging.BundleLogger; import info.nightscout.utils.JsonHelper; import info.nightscout.utils.SP; public class DataService extends IntentService { - private Logger log = LoggerFactory.getLogger(Constants.DATASERVICE); + private Logger log = LoggerFactory.getLogger(L.DATASERVICE); public DataService() { super("DataService"); @@ -48,7 +47,7 @@ public class DataService extends IntentService { @Override protected void onHandleIntent(final Intent intent) { - if (Config.logDataService) { + if (L.isEnabled(L.DATASERVICE)) { log.debug("onHandleIntent " + intent); log.debug("onHandleIntent " + BundleLogger.log(intent.getExtras())); } @@ -101,7 +100,7 @@ public class DataService extends IntentService { SmsCommunicatorPlugin.getPlugin().handleNewData(intent); } - if (Config.logDataService) + if (L.isEnabled(L.DATASERVICE)) log.debug("onHandleIntent exit " + intent); DataReceiver.completeWakefulIntent(intent); } @@ -124,7 +123,7 @@ public class DataService extends IntentService { private void handleNewDataFromNSClient(Intent intent) { Bundle bundles = intent.getExtras(); if (bundles == null) return; - if (Config.logDataService) + if (L.isEnabled(L.DATASERVICE)) log.debug("Got intent: " + intent.getAction()); @@ -254,7 +253,7 @@ public class DataService extends IntentService { NSMbg nsMbg = new NSMbg(mbgJson); CareportalEvent careportalEvent = new CareportalEvent(nsMbg); MainApp.getDbHelper().createOrUpdate(careportalEvent); - if (Config.logDataService) + if (L.isEnabled(L.DATASERVICE)) log.debug("Adding/Updating new MBG: " + careportalEvent.log()); }