From 965c56d9e14d9cb51a8549fd0881832654354622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lenclud?= Date: Tue, 26 Sep 2023 08:49:50 +0200 Subject: [PATCH] Log cookies when page is loaded Migrate locale logs to Timber. --- .../preferences/LocaleListPreference.java | 15 +++++++++------ .../browser/lightning/view/LightningWebClient.kt | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/settings/preferences/LocaleListPreference.java b/app/src/main/java/acr/browser/lightning/settings/preferences/LocaleListPreference.java index 97063dd76..842be0537 100644 --- a/app/src/main/java/acr/browser/lightning/settings/preferences/LocaleListPreference.java +++ b/app/src/main/java/acr/browser/lightning/settings/preferences/LocaleListPreference.java @@ -36,9 +36,12 @@ import acr.browser.lightning.locale.LocaleUtils; import kotlin.Pair; +import timber.log.Timber; +/** + * Taken from GeckoLocaleList + */ public class LocaleListPreference extends ListPreference { - private static final String LOG_TAG = "GeckoLocaleList"; private static final Map languageCodeToNameMap = new HashMap<>(); private static final Map localeToNameMap = new HashMap<>(); @@ -184,10 +187,10 @@ public void onAttached() { private void initializeLocaleList() { final Locale currentLocale = Locale.getDefault(); - Log.d(LOG_TAG, "Building locales list. Current locale: " + currentLocale); + Timber.d("Building locales list. Current locale: " + currentLocale); if (currentLocale.equals(this.entriesLocale) && getEntries() != null) { - Log.v(LOG_TAG, "No need to build list."); + Timber.v("No need to build list."); return; } @@ -236,7 +239,7 @@ public LocaleDescriptor(Locale locale, String tag) { if (TextUtils.isEmpty(displayName)) { // There's nothing sane we can do. - Log.w(LOG_TAG, "Display name is empty. Using " + locale.toString()); + Timber.w("Display name is empty. Using " + locale.toString()); this.nativeName = locale.toString(); return; } @@ -389,7 +392,7 @@ protected Pair doInBackground(Void... voids) { for (int i = 0; i < count; ++i) { final String displayName = descriptors[i].getDisplayName(); final String tag = descriptors[i].getTag(); - Log.v(LOG_TAG, displayName + " => " + tag); + Timber.v(displayName + " => " + tag); entries[i + 1] = displayName; values[i + 1] = tag; } @@ -408,7 +411,7 @@ private LocaleDescriptor[] getUsableLocales() { for (String tag : shippingLocales) { final LocaleDescriptor descriptor = new LocaleDescriptor(tag); if (!descriptor.isUsable(this.characterValidator)) { - Log.w(LOG_TAG, "Skipping locale " + tag + " on this device."); + Timber.w("Skipping locale " + tag + " on this device."); continue; } diff --git a/app/src/main/java/acr/browser/lightning/view/LightningWebClient.kt b/app/src/main/java/acr/browser/lightning/view/LightningWebClient.kt index 96b37bec1..ef5a91603 100644 --- a/app/src/main/java/acr/browser/lightning/view/LightningWebClient.kt +++ b/app/src/main/java/acr/browser/lightning/view/LightningWebClient.kt @@ -1,6 +1,5 @@ package acr.browser.lightning.view -import fulguris.app import acr.browser.lightning.BuildConfig import acr.browser.lightning.R import acr.browser.lightning.adblock.AbpBlockerManager @@ -51,12 +50,14 @@ import androidx.core.content.res.ResourcesCompat import androidx.core.graphics.drawable.toBitmap import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.EntryPointAccessors +import fulguris.LogLevel +import fulguris.app +import timber.log.Timber import java.io.ByteArrayOutputStream import java.io.File import java.net.URISyntaxException import java.util.* import kotlin.math.abs -import timber.log.Timber /** * @@ -241,6 +242,15 @@ class LightningWebClient( } uiController.tabChanged(lightningView) + + // To prevent potential overhead when logs are not needed + if (userPreferences.logs && userPreferences.logLevel== LogLevel.VERBOSE) { + val cookies = CookieManager.getInstance().getCookie(url).split(';') + Timber.v("Cookies count: ${cookies.count()}") + cookies.forEach { + Timber.v(it.trim()) + } + } } /**