From 5ef9bc7948a68097276304cb2d45e5cb47207536 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 29 Jul 2018 00:20:41 +0200 Subject: [PATCH] cleanup --- .../info/nightscout/androidaps/Config.java | 42 +++++++++---------- .../androidaps/db/DatabaseHelper.java | 10 ++--- .../NSClientInternal/data/DbLogger.java | 4 +- .../services/NSClientService.java | 15 +++---- .../plugins/ProfileNS/NSProfilePlugin.java | 2 +- .../androidaps/receivers/DataReceiver.java | 5 ++- .../androidaps/services/DataService.java | 4 +- 7 files changed, 39 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index 3ee273207a..361ccf33f0 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -23,28 +23,26 @@ public class Config { public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER; - public static final boolean detailedLog = true; - public static final boolean logFunctionCalls = true; - public static final boolean logIncommingData = true; - public static final boolean logAPSResult = true; - public static final boolean logPrefsChange = true; - public static final boolean logConfigBuilder = true; - public static final boolean logNSUpload = true; - public static final boolean logCongigBuilderActions = true; - public static final boolean logAutosensData = false; - public static final boolean logEvents = false; - public static final boolean logQueue = true; - public static final boolean logBgSource = true; - public static final boolean logOverview = true; - public static final boolean logNotification = true; - public static final boolean logAlarm = false; - public static final boolean logDataService = true; - public static final boolean logDataFood = true; - public static final boolean logDataTreatments = true; - public static final boolean logNsclient = true; - public static final boolean logObjectives = false; - public static final boolean logPump = true; + public static boolean logFunctionCalls = true; + public static boolean logAPSResult = true; + 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 final boolean logPumpBtComm = false; + public static boolean logPumpBtComm = false; } 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 19a20bdfc4..c0aff525ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -769,7 +769,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.logIncommingData) + if (Config.logDatabase) log.debug("Updating _id in DanaR history database: " + trJson.getString("_id")); record._id = trJson.getString("_id"); getDaoDanaRHistory().update(record); @@ -1320,11 +1320,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { if (list.size() == 1) { CareportalEvent record = list.get(0); - if (Config.logIncommingData) + if (Config.logDatabase) log.debug("Removing CareportalEvent record from database: " + record.log()); delete(record); } else { - if (Config.logIncommingData) + if (Config.logDatabase) log.debug("CareportalEvent not found database: " + _id); } } catch (SQLException e) { @@ -1344,12 +1344,12 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { if (list.size() == 0) { careportalEvent = new CareportalEvent(); careportalEvent.source = Source.NIGHTSCOUT; - if (Config.logIncommingData) + if (Config.logDatabase) 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.logIncommingData) + if (Config.logDatabase) log.debug("Updating CareportalEvent record in database: " + trJson.toString()); } else { log.error("Something went wrong"); 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 4c237d91c9..8ab0e783cf 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 @@ -25,7 +25,7 @@ public class DbLogger { if (q.size() < 1) { ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.nsclientnotinstalled)); log.error("DBADD No receivers"); - } else if (Config.logNSUpload) { + } else if (Config.logNsclient) { if (Config.logNsclient) log.debug("DBADD dbAdd " + q.size() + " receivers " + data); } @@ -36,7 +36,7 @@ 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.logNSUpload) { + } else if (Config.logNsclient) { if (Config.logNsclient) log.debug("DBREMOVE dbRemove " + q.size() + " receivers " + data); } 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 a97069f015..536a9fe819 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 @@ -9,7 +9,6 @@ import android.os.HandlerThread; import android.os.IBinder; import android.os.PowerManager; - import com.google.common.base.Charsets; import com.google.common.hash.Hashing; import com.j256.ormlite.dao.CloseableIterator; @@ -23,7 +22,6 @@ import org.slf4j.LoggerFactory; import java.net.URISyntaxException; import java.sql.SQLException; -import java.util.Date; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; @@ -356,13 +354,12 @@ public class NSClientService extends Service { log.error("Unhandled exception", e); return; } - if (Config.detailedLog) - try { - MainApp.bus().post(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(data, "message", "received"))); - } catch (Exception e) { - FabricPrivacy.logException(e); - log.error("Unhandled exception", e); - } + try { + MainApp.bus().post(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(data, "message", "received"))); + } catch (Exception e) { + FabricPrivacy.logException(e); + log.error("Unhandled exception", e); + } BroadcastAnnouncement.handleAnnouncement(data, getApplicationContext()); if (Config.logNsclient) log.debug(data.toString()); 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 98afb4f004..e86772fc36 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 @@ -77,7 +77,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface { MainApp.bus().post(new EventProfileStoreChanged()); MainApp.bus().post(new EventNSProfileUpdateGUI()); } - if (Config.logIncommingData) + if (Config.logNsclient) log.debug("Received profileStore: " + activeProfile + " " + profile); } catch (JSONException e) { log.error("Unhandled exception", e); 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 7e3597c0f3..535f64c85f 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.java @@ -7,15 +7,16 @@ import android.support.v4.content.WakefulBroadcastReceiver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.services.DataService; import info.nightscout.androidaps.Config; public class DataReceiver extends WakefulBroadcastReceiver { - private static Logger log = LoggerFactory.getLogger(DataReceiver.class); + private static Logger log = LoggerFactory.getLogger(Constants.DATASERVICE); @Override public void onReceive(Context context, Intent intent) { - if (Config.logFunctionCalls) + if (Config.logDataService) 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/DataService.java b/app/src/main/java/info/nightscout/androidaps/services/DataService.java index e790da3a5f..95b3e70195 100644 --- a/app/src/main/java/info/nightscout/androidaps/services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/services/DataService.java @@ -124,7 +124,7 @@ public class DataService extends IntentService { private void handleNewDataFromNSClient(Intent intent) { Bundle bundles = intent.getExtras(); if (bundles == null) return; - if (Config.logIncommingData) + if (Config.logDataService) log.debug("Got intent: " + intent.getAction()); @@ -254,7 +254,7 @@ public class DataService extends IntentService { NSMbg nsMbg = new NSMbg(mbgJson); CareportalEvent careportalEvent = new CareportalEvent(nsMbg); MainApp.getDbHelper().createOrUpdate(careportalEvent); - if (Config.logIncommingData) + if (Config.logDataService) log.debug("Adding/Updating new MBG: " + careportalEvent.log()); }