From 22d7dda7579cc4c808f184186b0a53880146add8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 23 Apr 2022 16:20:50 +0200 Subject: [PATCH] Log -> AAPSLogger --- .../profile/local/LocalProfileFragment.kt | 4 ++-- .../androidaps/utils/wizard/QuickWizard.kt | 3 +-- .../pump/common/utils/DateTimeUtilUTest.java | 4 +--- .../ComplicationTapBroadcastReceiver.java | 8 ++++---- .../androidaps/interaction/utils/Inevitable.java | 16 ++++++++-------- .../androidaps/watchfaces/DigitalStyle.java | 12 ++++++------ 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index 63312f8df9..c1c0959d68 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.profile.local import android.os.Bundle import android.text.Editable import android.text.TextWatcher -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -38,6 +37,7 @@ import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.ui.TimeListEdit import info.nightscout.shared.SafeParse import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.kotlin.plusAssign import java.math.RoundingMode @@ -196,7 +196,7 @@ class LocalProfileFragment : DaggerFragment() { roundUp(Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_MAX_BG[0], GlucoseUnit.MMOL)), roundDown(Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_MAX_BG[1], GlucoseUnit.MMOL)) ) - Log.i("TimeListEdit", "build: range1" + range1[0] + " " + range1[1] + " range2" + range2[0] + " " + range2[1]) + aapsLogger.info(LTag.CORE, "TimeListEdit", "build: range1" + range1[0] + " " + range1[1] + " range2" + range2[0] + " " + range2[1]) TimeListEdit( context, aapsLogger, diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizard.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizard.kt index 450ce43d46..88a4d4edc5 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizard.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizard.kt @@ -1,6 +1,5 @@ package info.nightscout.androidaps.utils.wizard -import android.util.Log import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.shared.sharedPreferences.SP @@ -72,7 +71,7 @@ class QuickWizard @Inject constructor( } fun move(from: Int, to: Int) { - Log.i("QuickWizard", "moveItem: $from $to") + //Log.i("QuickWizard", "moveItem: $from $to") val fromEntry = storage[from] as JSONObject storage.remove(from) addToPos(to, fromEntry, storage) diff --git a/core/src/test/java/info/nightscout/androidaps/pump/common/utils/DateTimeUtilUTest.java b/core/src/test/java/info/nightscout/androidaps/pump/common/utils/DateTimeUtilUTest.java index f5557f5eff..8a8bc558b7 100644 --- a/core/src/test/java/info/nightscout/androidaps/pump/common/utils/DateTimeUtilUTest.java +++ b/core/src/test/java/info/nightscout/androidaps/pump/common/utils/DateTimeUtilUTest.java @@ -1,7 +1,5 @@ package info.nightscout.androidaps.pump.common.utils; -import android.util.Log; - import org.junit.Assert; import org.junit.Test; @@ -19,7 +17,7 @@ public class DateTimeUtilUTest { Assert.assertEquals(65, aTechDateDifferenceAsMinutes); - Log.d("DateTimeUtilUTest", "Time difference: " + aTechDateDifferenceAsMinutes); + //Log.d("DateTimeUtilUTest", "Time difference: " + aTechDateDifferenceAsMinutes); } } \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/complications/ComplicationTapBroadcastReceiver.java b/wear/src/main/java/info/nightscout/androidaps/complications/ComplicationTapBroadcastReceiver.java index 158ad0f3e1..96b0b36412 100644 --- a/wear/src/main/java/info/nightscout/androidaps/complications/ComplicationTapBroadcastReceiver.java +++ b/wear/src/main/java/info/nightscout/androidaps/complications/ComplicationTapBroadcastReceiver.java @@ -6,7 +6,6 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.wearable.complications.ProviderUpdateRequester; -import android.util.Log; import android.widget.Toast; import androidx.annotation.StringRes; @@ -23,6 +22,8 @@ import info.nightscout.androidaps.interaction.menus.StatusMenuActivity; import info.nightscout.androidaps.interaction.utils.Constants; import info.nightscout.androidaps.interaction.utils.DisplayFormat; import info.nightscout.androidaps.interaction.utils.WearUtil; +import info.nightscout.shared.logging.AAPSLogger; +import info.nightscout.shared.logging.LTag; import info.nightscout.shared.sharedPreferences.SP; /* @@ -33,8 +34,7 @@ public class ComplicationTapBroadcastReceiver extends DaggerBroadcastReceiver { @Inject WearUtil wearUtil; @Inject DisplayFormat displayFormat; @Inject SP sp; - - private static final String TAG = ComplicationTapBroadcastReceiver.class.getSimpleName(); + @Inject AAPSLogger aapsLogger; private static final String EXTRA_PROVIDER_COMPONENT = "info.nightscout.androidaps.complications.action.PROVIDER_COMPONENT"; @@ -58,7 +58,7 @@ public class ComplicationTapBroadcastReceiver extends DaggerBroadcastReceiver { action = ComplicationAction.valueOf(ComplicationAction.class, complicationAction); } catch (IllegalArgumentException | NullPointerException ex) { // but how? - Log.e(TAG, "Cannot interpret complication action: " + complicationAction); + aapsLogger.error(LTag.WEAR, "Cannot interpret complication action: " + complicationAction); } action = remapActionWithUserPreferences(action); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/Inevitable.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/Inevitable.java index 5e97469c0c..b0d40d6b64 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/Inevitable.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/Inevitable.java @@ -1,7 +1,6 @@ package info.nightscout.androidaps.interaction.utils; import android.os.PowerManager; -import android.util.Log; import java.util.concurrent.ConcurrentHashMap; @@ -9,6 +8,8 @@ import javax.inject.Inject; import javax.inject.Singleton; import info.nightscout.androidaps.BuildConfig; +import info.nightscout.shared.logging.AAPSLogger; +import info.nightscout.shared.logging.LTag; /** * Created for xDrip by jamorham on 07/03/2018 @@ -23,10 +24,10 @@ import info.nightscout.androidaps.BuildConfig; public class Inevitable { @Inject WearUtil wearUtil; + @Inject AAPSLogger aapsLogger; @Inject Inevitable() {} - private static final String TAG = Inevitable.class.getSimpleName(); private static final int MAX_QUEUE_TIME = (int) Constants.MINUTE_IN_MS * 6; private static final boolean debug = BuildConfig.DEBUG; @@ -42,15 +43,14 @@ public class Inevitable { task.extendTime(idle_for); if (debug) - Log.d(TAG, "Extending time for: " + id + " to " + wearUtil.dateTimeText(task.when)); + aapsLogger.debug(LTag.WEAR, "Extending time for: " + id + " to " + wearUtil.dateTimeText(task.when)); } else { // otherwise create new task if (runnable == null) return; // extension only if already exists tasks.put(id, new Task(id, idle_for, runnable)); if (debug) { - Log.d(TAG, - "Creating task: " + id + " due: " + wearUtil.dateTimeText(tasks.get(id).when)); + aapsLogger.debug(LTag.WEAR, "Creating task: " + id + " due: " + wearUtil.dateTimeText(tasks.get(id).when)); } // create a thread to wait and execute in background @@ -79,7 +79,7 @@ public class Inevitable { stack++; } if (stack > 0) { - Log.d(TAG, "Task stacked to: " + id); + aapsLogger.debug(LTag.WEAR, "Task stacked to: " + id); } task(id, idle_for, runnable); } @@ -110,12 +110,12 @@ public class Inevitable { public boolean poll() { final long till = wearUtil.msTill(when); if (till < 1) { - if (debug) Log.d(TAG, "Executing task! " + this.id); + if (debug) aapsLogger.debug(LTag.WEAR, "Executing task! " + this.id); tasks.remove(this.id); // early remove to allow overlapping scheduling what.run(); return true; } else if (till > MAX_QUEUE_TIME) { - Log.wtf(TAG, "Task: " + this.id + " In queue too long: " + till); + aapsLogger.debug(LTag.WEAR, "Task: " + this.id + " In queue too long: " + till); tasks.remove(this.id); return true; } diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyle.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyle.java index a780b14ff8..d9eb309742 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyle.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyle.java @@ -4,7 +4,6 @@ import android.annotation.SuppressLint; import android.content.Intent; import android.content.res.ColorStateList; import android.support.wearable.watchface.WatchFaceStyle; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.LinearLayout; @@ -17,6 +16,7 @@ import java.util.Date; import info.nightscout.androidaps.R; import info.nightscout.androidaps.interaction.menus.MainMenuActivity; +import info.nightscout.shared.logging.LTag; public class DigitalStyle extends BaseWatchFace { private static final long TIME_TAP_THRESHOLD = 800; @@ -34,7 +34,7 @@ public class DigitalStyle extends BaseWatchFace { @Override protected void onTapCommand(int tapType, int x, int y, long eventTime) { //tapType = TAP_TYPE_TAP; - Log.d("onTapCommand: DeviceWidth x DeviceHeight /// x , y, TapType >> ", getWidth() + " x " + getHeight() + " /// " + x + " , " + y + " , " + tapType); + aapsLogger.debug(LTag.WEAR,"onTapCommand: DeviceWidth x DeviceHeight /// x , y, TapType >> ", getWidth() + " x " + getHeight() + " /// " + x + " , " + y + " , " + tapType); if (tapType == TAP_TYPE_TAP) { if (eventTime - sgvTapTime < TIME_TAP_THRESHOLD) { @@ -111,7 +111,7 @@ public class DigitalStyle extends BaseWatchFace { try { mShapesElements.setBackground(getResources().getDrawable(getResources().getIdentifier(styleDrawableName, "drawable", getApplicationContext().getPackageName()))); } catch (Exception e) { - Log.e("digitalstyle_frameStyle", "RESOURCE NOT FOUND >> " + styleDrawableName); + aapsLogger.error("digitalstyle_frameStyle", "RESOURCE NOT FOUND >> " + styleDrawableName); } // set background-tint-color @@ -119,13 +119,13 @@ public class DigitalStyle extends BaseWatchFace { mShapesElements.setBackgroundTintList(null); } else { String strColorName =(( displayFrameColor.equals("white") || displayFrameColor.equals("black") )?displayFrameColor:displayFrameColor+"_"+displayFrameColorSaturation); - Log.v("digitalstyle_strColorName",strColorName); + aapsLogger.debug(LTag.WEAR,"digitalstyle_strColorName",strColorName); try { ColorStateList colorStateList = ContextCompat.getColorStateList(getApplicationContext(), getResources().getIdentifier(strColorName, "color", getApplicationContext().getPackageName())); mShapesElements.setBackgroundTintList(colorStateList); } catch (Exception e) { mShapesElements.setBackgroundTintList(null); - Log.e("digitalstyle_colorName", "COLOR NOT FOUND >> " + strColorName); + aapsLogger.error("digitalstyle_colorName", "COLOR NOT FOUND >> " + strColorName); } } @@ -151,7 +151,7 @@ public class DigitalStyle extends BaseWatchFace { /* display week number */ Boolean isShowWeekNumber = sp.getBoolean("show_weeknumber", false); - Log.i("---------------------------------","weeknumber refresh "); + aapsLogger.info(LTag.WEAR,"---------------------------------","weeknumber refresh "); TextView mWeekNumber= layoutView.findViewById(R.id.weeknumber); if (isShowWeekNumber) { mWeekNumber.setVisibility(View.VISIBLE);