Skip to content

Commit

Permalink
Log cookies when page is loaded
Browse files Browse the repository at this point in the history
Migrate locale logs to Timber.
  • Loading branch information
Slion committed Sep 26, 2023
1 parent 75a992d commit 965c56d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> languageCodeToNameMap = new HashMap<>();
private static final Map<String, String> localeToNameMap = new HashMap<>();
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -389,7 +392,7 @@ protected Pair<String[], String[]> 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;
}
Expand All @@ -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;
}

Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/acr/browser/lightning/view/LightningWebClient.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

/**
*
Expand Down Expand Up @@ -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())
}
}
}

/**
Expand Down

0 comments on commit 965c56d

Please sign in to comment.