dagger logging start

This commit is contained in:
AdrianLxM 2019-12-28 01:52:20 +01:00
parent a2d2dd38e3
commit 9a72912281
11 changed files with 202 additions and 144 deletions

View file

@ -34,9 +34,6 @@ import com.google.android.material.tabs.TabLayout;
import com.joanzapata.iconify.Iconify;
import com.joanzapata.iconify.fonts.FontAwesomeModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import dagger.android.AndroidInjection;
@ -53,7 +50,8 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRebuildTabs;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtilsKt;
@ -71,7 +69,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
public class MainActivity extends NoSplashAppCompatActivity implements HasAndroidInjector {
private static Logger log = LoggerFactory.getLogger(L.CORE);
@Inject
DispatchingAndroidInjector<Object> androidInjector;
@ -85,6 +82,9 @@ public class MainActivity extends NoSplashAppCompatActivity implements HasAndroi
@Inject
SmsCommunicatorPlugin smsCommunicatorPlugin;
@Inject
AAPSLogger aapsLogger;
@Override
public void onCreate(Bundle savedInstanceState) {
AndroidInjection.inject(this);
@ -327,7 +327,7 @@ public class MainActivity extends NoSplashAppCompatActivity implements HasAndroi
((TextView) alertDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
return true;
case R.id.nav_exit:
log.debug("Exiting");
aapsLogger.debug(LTag.CORE, "Exiting");
RxBus.INSTANCE.send(new EventAppExit());
finish();
System.runFinalization();

View file

@ -33,7 +33,9 @@ import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
@ -121,12 +123,20 @@ public class MainApp extends DaggerApplication {
public static boolean devBranch;
public static boolean engineeringMode;
@Inject ConfigBuilderPlugin configBuilderPlugin;
@Inject
AAPSLogger aapsLogger;
@Inject InsulinOrefFreePeakPlugin insulinOrefFreePeakPlugin;
@Inject InsulinOrefRapidActingPlugin insulinOrefRapidActingPlugin;
@Inject InsulinOrefUltraRapidActingPlugin insulinOrefUltraRapidActingPlugin;
@Inject SmsCommunicatorPlugin smsCommunicatorPlugin;
@Inject
ConfigBuilderPlugin configBuilderPlugin;
@Inject
InsulinOrefFreePeakPlugin insulinOrefFreePeakPlugin;
@Inject
InsulinOrefRapidActingPlugin insulinOrefRapidActingPlugin;
@Inject
InsulinOrefUltraRapidActingPlugin insulinOrefUltraRapidActingPlugin;
@Inject
SmsCommunicatorPlugin smsCommunicatorPlugin;
@Override
public void onCreate() {
@ -433,8 +443,8 @@ public class MainApp extends DaggerApplication {
@Override
public void onTerminate() {
if (L.isEnabled(L.CORE))
log.debug("onTerminate");
aapsLogger.debug(LTag.CORE, "onTerminate");
if (timeDateOrTZChangeReceiver != null)
unregisterReceiver(timeDateOrTZChangeReceiver);

View file

@ -6,7 +6,11 @@ import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.AAPSLoggerDebug
import info.nightscout.androidaps.logging.AAPSLoggerProduction
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctionImplementation
@ -46,6 +50,16 @@ class AppModule {
return ResourceHelperImplementation(mainApp)
}
@Provides
@Singleton
fun provideAAPSLogger(): AAPSLogger {
return if (BuildConfig.DEBUG) {
AAPSLoggerDebug()
} else {
AAPSLoggerProduction()
}
}
@Module
interface AppBindings {

View file

@ -1,62 +0,0 @@
package info.nightscout.androidaps.interfaces
import info.nightscout.androidaps.data.Profile
interface ConstraintsInterface {
fun isLoopInvocationAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
fun isClosedLoopAllowed(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
fun isAutosensModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
fun isAMAModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
fun isSMBModeEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
fun isUAMEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
fun isAdvancedFilteringEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
fun isSuperBolusEnabled(value: Constraint<Boolean>): Constraint<Boolean> {
return value
}
fun applyBasalConstraints(absoluteRate: Constraint<Double>, profile: Profile): Constraint<Double> {
return absoluteRate
}
fun applyBasalPercentConstraints(percentRate: Constraint<Int>, profile: Profile): Constraint<Int> {
return percentRate
}
fun applyBolusConstraints(insulin: Constraint<Double>): Constraint<Double> {
return insulin
}
fun applyExtendedBolusConstraints(insulin: Constraint<Double>): Constraint<Double> {
return insulin
}
fun applyCarbsConstraints(carbs: Constraint<Int>): Constraint<Int> {
return carbs
}
fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
return maxIob
}
}

View file

@ -0,0 +1,13 @@
package info.nightscout.androidaps.logging
/**
* Created by adrian on 2019-12-27.
*/
interface AAPSLogger {
fun debug(tag: LTag, message: String)
fun info(tag: LTag, message: String)
fun error(tag: LTag, message: String)
fun error(tag: LTag, message: String, throwable: Throwable)
}

View file

@ -0,0 +1,28 @@
package info.nightscout.androidaps.logging
import android.util.Log
/**
* Created by adrian on 2019-12-27.
*/
class AAPSLoggerDebug : AAPSLogger {
override fun debug(tag: LTag, message: String) {
Log.d(tag.tag, message)
}
override fun info(tag: LTag, message: String) {
Log.i(tag.tag, message)
}
override fun error(tag: LTag, message: String) {
Log.e(tag.tag, message)
}
override fun error(tag: LTag, message: String, throwable: Throwable) {
Log.e(tag.tag, message, throwable)
}
}

View file

@ -0,0 +1,38 @@
package info.nightscout.androidaps.logging
import org.slf4j.LoggerFactory
/**
* Created by adrian on 2019-12-27.
*/
class AAPSLoggerProduction : AAPSLogger {
override fun debug(tag: LTag, message: String) {
if (L.isEnabled(tag.tag)) {
LoggerFactory.getLogger(tag.tag).debug(message)
}
}
override fun info(tag: LTag, message: String) {
if (L.isEnabled(tag.tag)) {
LoggerFactory.getLogger(tag.tag).info(message)
}
}
override fun error(tag: LTag, message: String) {
if (L.isEnabled(tag.tag)) {
LoggerFactory.getLogger(tag.tag).error(message)
}
}
override fun error(tag: LTag, message: String, throwable: Throwable) {
if (L.isEnabled(tag.tag)) {
LoggerFactory.getLogger(tag.tag).error(message, throwable)
}
}
}

View file

@ -119,3 +119,31 @@ object L {
}
}
}
enum class LTag(val tag: String) {
CORE("CORE"),
AUTOSENS("AUTOSENS"),
AUTOMATION("AUTOMATION"),
EVENTS("EVENTS"),
GLUCOSE("GLUCOSE"),
BGSOURCE("BGSOURCE"),
OVERVIEW("OVERVIEW"),
NOTIFICATION("NOTIFICATION"),
DATASERVICE("DATASERVICE"),
DATABASE("DATABASE"),
DATAFOOD("DATAFOOD"),
DATATREATMENTS("DATATREATMENTS"),
NSCLIENT("NSCLIENT"),
TIDEPOOL("TIDEPOOL"),
CONSTRAINTS("CONSTRAINTS"),
PUMP("PUMP"),
PUMPQUEUE("PUMPQUEUE"),
PUMPCOMM("PUMPCOMM"),
PUMPBTCOMM("PUMPBTCOMM"),
APS("APS"),
PROFILE("PROFILE"),
CONFIGBUILDER("CONFIGBUILDER"),
UI("UI"),
LOCATION("LOCATION"),
SMS("SMS"),
}

View file

@ -3,8 +3,6 @@ package info.nightscout.androidaps.plugins.configBuilder;
import androidx.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
@ -24,7 +22,8 @@ import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.SensitivityInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin;
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin;
@ -39,9 +38,8 @@ import info.nightscout.androidaps.utils.SP;
*/
@Singleton
public class ConfigBuilderPlugin extends PluginBase {
private Logger log = LoggerFactory.getLogger(L.CONFIGBUILDER);
private static ConfigBuilderPlugin configBuilderPlugin;
private final AAPSLogger aapsLogger; // TODO move to plugin base
/**
@ -78,7 +76,10 @@ public class ConfigBuilderPlugin extends PluginBase {
* Lazy dependencies in this constructor.
* */
@Inject
public ConfigBuilderPlugin(Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin) {
public ConfigBuilderPlugin(
Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin,
AAPSLogger aapsLogger
) {
super(new PluginDescription()
.mainType(PluginType.GENERAL)
.fragmentClass(ConfigBuilderFragment.class.getName())
@ -90,6 +91,7 @@ public class ConfigBuilderPlugin extends PluginBase {
.description(R.string.description_config_builder)
);
this.insulinOrefRapidActingPlugin = insulinOrefRapidActingPlugin;
this.aapsLogger = aapsLogger;
configBuilderPlugin = this; // TODO: only while transitioning to Dagger
}
@ -122,8 +124,7 @@ public class ConfigBuilderPlugin extends PluginBase {
public void storeSettings(String from) {
if (pluginList != null) {
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Storing settings from: " + from);
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing settings from: " + from);
verifySelectionInCategories();
@ -146,19 +147,16 @@ public class ConfigBuilderPlugin extends PluginBase {
private void savePref(PluginBase p, PluginType type, boolean storeVisible) {
String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled";
SP.putBoolean(settingEnabled, p.isEnabled(type));
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Storing: " + settingEnabled + ":" + p.isEnabled(type));
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing: " + settingEnabled + ":" + p.isEnabled(type));
if (storeVisible) {
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
SP.putBoolean(settingVisible, p.isFragmentVisible());
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Storing: " + settingVisible + ":" + p.isFragmentVisible());
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing: " + settingVisible + ":" + p.isFragmentVisible());
}
}
private void loadSettings() {
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Loading stored settings");
aapsLogger.debug(LTag.CONFIGBUILDER, "Loading stored settings");
for (PluginBase p : pluginList) {
PluginType type = p.getType();
loadPref(p, type, true);
@ -178,8 +176,7 @@ public class ConfigBuilderPlugin extends PluginBase {
else if (p.getType() == type && (p.pluginDescription.enableByDefault || p.pluginDescription.alwaysEnabled)) {
p.setPluginEnabled(type, true);
}
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Loaded: " + settingEnabled + ":" + p.isEnabled(type));
aapsLogger.debug(LTag.CONFIGBUILDER, "Loaded: " + settingEnabled + ":" + p.isEnabled(type));
if (loadVisible) {
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
if (SP.contains(settingVisible))
@ -187,8 +184,7 @@ public class ConfigBuilderPlugin extends PluginBase {
else if (p.getType() == type && p.pluginDescription.visibleByDefault) {
p.setFragmentVisible(type, true);
}
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Loaded: " + settingVisible + ":" + p.isFragmentVisible());
aapsLogger.debug(LTag.CONFIGBUILDER, "Loaded: " + settingVisible + ":" + p.isFragmentVisible());
}
}
@ -196,11 +192,9 @@ public class ConfigBuilderPlugin extends PluginBase {
private void upgradeSettings() {
if (!SP.contains("ConfigBuilder_1_NSProfilePlugin_Enabled"))
return;
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Upgrading stored settings");
aapsLogger.debug(LTag.CONFIGBUILDER, "Upgrading stored settings");
for (PluginBase p : pluginList) {
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Processing " + p.getName());
aapsLogger.debug(LTag.CONFIGBUILDER, "Processing " + p.getName());
for (int type = 1; type < 11; type++) {
PluginType newType;
switch (type) {
@ -291,9 +285,8 @@ public class ConfigBuilderPlugin extends PluginBase {
}
public void logPluginStatus() {
if (L.isEnabled(L.CONFIGBUILDER))
for (PluginBase p : pluginList) {
log.debug(p.getName() + ":" +
aapsLogger.debug(LTag.CONFIGBUILDER, p.getName() + ":" +
(p.isEnabled(PluginType.GENERAL) ? " GENERAL" : "") +
(p.isEnabled(PluginType.TREATMENT) ? " TREATMENT" : "") +
(p.isEnabled(PluginType.SENSITIVITY) ? " SENSITIVITY" : "") +
@ -320,8 +313,7 @@ public class ConfigBuilderPlugin extends PluginBase {
if (activeInsulin == null) {
activeInsulin = insulinOrefRapidActingPlugin.get();
insulinOrefRapidActingPlugin.get().setPluginEnabled(PluginType.INSULIN, true);
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Defaulting InsulinOrefRapidActingPlugin");
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting InsulinOrefRapidActingPlugin");
}
this.setFragmentVisiblities(((PluginBase) activeInsulin).getName(), pluginsInCategory, PluginType.INSULIN);
@ -331,8 +323,7 @@ public class ConfigBuilderPlugin extends PluginBase {
if (activeSensitivity == null) {
activeSensitivity = SensitivityOref0Plugin.getPlugin();
SensitivityOref0Plugin.getPlugin().setPluginEnabled(PluginType.SENSITIVITY, true);
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Defaulting SensitivityOref0Plugin");
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting SensitivityOref0Plugin");
}
this.setFragmentVisiblities(((PluginBase) activeSensitivity).getName(), pluginsInCategory, PluginType.SENSITIVITY);
@ -348,8 +339,7 @@ public class ConfigBuilderPlugin extends PluginBase {
if (activePump == null) {
activePump = VirtualPumpPlugin.getPlugin();
VirtualPumpPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, true);
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Defaulting VirtualPumpPlugin");
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting VirtualPumpPlugin");
}
this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginType.PUMP);
@ -407,8 +397,7 @@ public class ConfigBuilderPlugin extends PluginBase {
private void setFragmentVisiblities(String activePluginName, ArrayList<PluginBase> pluginsInCategory,
PluginType pluginType) {
if (L.isEnabled(L.CONFIGBUILDER))
log.debug("Selected interface: " + activePluginName);
aapsLogger.debug(LTag.CONFIGBUILDER, "Selected interface: " + activePluginName);
for (PluginBase p : pluginsInCategory) {
if (!p.getName().equals(activePluginName)) {
p.setFragmentVisible(pluginType, false);

View file

@ -22,7 +22,9 @@ import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.L
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBus.send
import info.nightscout.androidaps.plugins.bus.RxBus.toObservable
@ -53,7 +55,8 @@ import javax.inject.Singleton
class SmsCommunicatorPlugin @Inject constructor(
val configBuilderPlugin: ConfigBuilderPlugin,
val resourceHelper: ResourceHelper,
val constraintChecker: ConstraintChecker
val constraintChecker: ConstraintChecker,
val aapsLogger: AAPSLogger
) : PluginBase(PluginDescription()
.mainType(PluginType.GENERAL)
.fragmentClass(SmsCommunicatorFragment::class.java.name)
@ -62,8 +65,6 @@ class SmsCommunicatorPlugin @Inject constructor(
.preferencesId(R.xml.pref_smscommunicator)
.description(R.string.description_sms_communicator)
) {
private val log = LoggerFactory.getLogger(L.SMS)
private val disposable = CompositeDisposable()
var allowedNumbers: MutableList<String> = ArrayList()
var messageToConfirm: AuthRequest? = null
@ -149,7 +150,7 @@ class SmsCommunicatorPlugin @Inject constructor(
for (number in substrings) {
val cleaned = number.replace("\\s+".toRegex(), "")
allowedNumbers.add(cleaned)
log.debug("Found allowed number: $cleaned")
aapsLogger.debug(LTag.SMS,"Found allowed number: $cleaned")
}
}
}
@ -181,11 +182,11 @@ class SmsCommunicatorPlugin @Inject constructor(
fun processSms(receivedSms: Sms) {
if (!isEnabled(PluginType.GENERAL)) {
log.debug("Ignoring SMS. Plugin disabled.")
aapsLogger.debug(LTag.SMS,"Ignoring SMS. Plugin disabled.")
return
}
if (!isAllowedNumber(receivedSms.phoneNumber)) {
log.debug("Ignoring SMS from: " + receivedSms.phoneNumber + ". Sender not allowed")
aapsLogger.debug(LTag.SMS,"Ignoring SMS from: " + receivedSms.phoneNumber + ". Sender not allowed")
receivedSms.ignored = true
messages.add(receivedSms)
send(EventSmsCommunicatorUpdateGui())
@ -193,7 +194,7 @@ class SmsCommunicatorPlugin @Inject constructor(
}
val pump = configBuilderPlugin.activePump ?: return
messages.add(receivedSms)
log.debug(receivedSms.toString())
aapsLogger.debug(LTag.SMS,receivedSms.toString())
val splitted = receivedSms.text.split(Regex("\\s+")).toTypedArray()
val remoteCommandsAllowed = SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)
if (splitted.isNotEmpty() && isCommand(splitted[0].toUpperCase(Locale.getDefault()), receivedSms.phoneNumber)) {
@ -858,7 +859,7 @@ class SmsCommunicatorPlugin @Inject constructor(
val smsManager = SmsManager.getDefault()
sms.text = stripAccents(sms.text)
try {
if (L.isEnabled(L.SMS)) log.debug("Sending SMS to " + sms.phoneNumber + ": " + sms.text)
aapsLogger.debug(LTag.SMS,"Sending SMS to " + sms.phoneNumber + ": " + sms.text)
if (sms.text.toByteArray().size <= 140) smsManager.sendTextMessage(sms.phoneNumber, null, sms.text, null, null)
else {
val parts = smsManager.divideMessage(sms.text)

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.services;
import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Telephony;
@ -19,8 +18,10 @@ 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.AAPSLogger;
import info.nightscout.androidaps.logging.BundleLogger;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus;
import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg;
@ -44,7 +45,6 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
public class DataService extends DaggerIntentService {
private Logger log = LoggerFactory.getLogger(L.DATASERVICE);
public DataService() {
super("DataService");
@ -53,15 +53,17 @@ public class DataService extends DaggerIntentService {
@Inject
SmsCommunicatorPlugin smsCommunicatorPlugin;
@Inject
AAPSLogger aapsLogger;
@Inject
SP sp;
@Override
protected void onHandleIntent(final Intent intent) {
if (L.isEnabled(L.DATASERVICE)) {
log.debug("onHandleIntent " + intent);
log.debug("onHandleIntent " + BundleLogger.log(intent.getExtras()));
}
aapsLogger.debug(LTag.DATASERVICE, "onHandleIntent " + intent);
aapsLogger.debug(LTag.DATASERVICE, "onHandleIntent " + BundleLogger.log(intent.getExtras()));
boolean acceptNSData = !sp.getBoolean(R.string.key_ns_upload_only, false);
Bundle bundles = intent.getExtras();
@ -111,8 +113,7 @@ public class DataService extends DaggerIntentService {
smsCommunicatorPlugin.handleNewData(intent);
}
if (L.isEnabled(L.DATASERVICE))
log.debug("onHandleIntent exit " + intent);
aapsLogger.debug(LTag.DATASERVICE, "onHandleIntent exit " + intent);
DataReceiver.completeWakefulIntent(intent);
}
@ -124,8 +125,7 @@ public class DataService extends DaggerIntentService {
private void handleNewDataFromNSClient(Intent intent) {
Bundle bundles = intent.getExtras();
if (bundles == null) return;
if (L.isEnabled(L.DATASERVICE))
log.debug("Got intent: " + intent.getAction());
aapsLogger.debug(LTag.DATASERVICE, "Got intent: " + intent.getAction());
if (intent.getAction().equals(Intents.ACTION_NEW_TREATMENT) || intent.getAction().equals(Intents.ACTION_CHANGED_TREATMENT)) {
@ -143,7 +143,7 @@ public class DataService extends DaggerIntentService {
}
}
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error(LTag.DATASERVICE, "Unhandled exception", e);
}
}
@ -164,7 +164,7 @@ public class DataService extends DaggerIntentService {
}
}
} catch (JSONException e) {
log.error("Unhandled exception", e);
aapsLogger.error(LTag.DATASERVICE, "Unhandled exception", e);
}
}
@ -185,7 +185,7 @@ public class DataService extends DaggerIntentService {
}
}
} catch (Exception e) {
log.error("Unhandled exception", e);
aapsLogger.error(LTag.DATASERVICE, "Unhandled exception", e);
}
}
}
@ -210,7 +210,7 @@ public class DataService extends DaggerIntentService {
double carbs = JsonHelper.safeGetDouble(json, "carbs");
String eventType = JsonHelper.safeGetString(json, "eventType");
if (eventType == null) {
log.debug("Wrong treatment. Ignoring : " + json.toString());
aapsLogger.debug(LTag.DATASERVICE, "Wrong treatment. Ignoring : " + json.toString());
return;
}
if (insulin > 0 || carbs > 0) {
@ -258,8 +258,7 @@ public class DataService extends DaggerIntentService {
NSMbg nsMbg = new NSMbg(mbgJson);
CareportalEvent careportalEvent = new CareportalEvent(nsMbg);
MainApp.getDbHelper().createOrUpdate(careportalEvent);
if (L.isEnabled(L.DATASERVICE))
log.debug("Adding/Updating new MBG: " + careportalEvent.toString());
aapsLogger.debug(LTag.DATASERVICE, "Adding/Updating new MBG: " + careportalEvent.toString());
}
}