From 272be36dd934f3ae50343983bad70132099d81bf Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Fri, 5 Nov 2021 18:04:49 +0100 Subject: [PATCH] Removed ``e.printStacktrace`` and used an proper logger --- .../java/org/schabi/newpipe/local/feed/FeedFragment.kt | 3 ++- .../main/java/org/schabi/newpipe/player/Player.java | 5 ++--- .../schabi/newpipe/settings/ContentSettingsManager.kt | 10 +++++++--- .../schabi/newpipe/util/TLSSocketFactoryCompat.java | 7 ++++--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt index 965075bf3..48427d174 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt @@ -25,6 +25,7 @@ import android.content.Intent import android.content.SharedPreferences import android.os.Bundle import android.os.Parcelable +import android.util.Log import android.view.LayoutInflater import android.view.Menu import android.view.MenuInflater @@ -464,7 +465,7 @@ class FeedFragment : BaseStateFragment() { errors.subList(i + 1, errors.size) ) }, - { throwable -> throwable.printStackTrace() } + { throwable -> Log.e(TAG, "Unable to process", throwable) } ) return // this will be called on the remaining errors by handleFeedNotAvailable() } diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 5435b9f81..fb903813c 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -695,7 +695,7 @@ public final class Player implements }, error -> { if (DEBUG) { - error.printStackTrace(); + Log.w(TAG, "Failed to start playback", error); } // In case any error we can start playback without history initPlayback(newQueue, repeatMode, playbackSpeed, playbackPitch, @@ -4184,8 +4184,7 @@ public final class Player implements } catch (@NonNull final IndexOutOfBoundsException e) { // Why would this even happen =(... but lets log it anyway, better safe than sorry if (DEBUG) { - Log.d(TAG, "player.isCurrentWindowDynamic() failed: " + e.getMessage()); - e.printStackTrace(); + Log.d(TAG, "player.isCurrentWindowDynamic() failed: ", e); } return false; } diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsManager.kt b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsManager.kt index 6bc63a56a..3ac275695 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsManager.kt +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsManager.kt @@ -1,6 +1,7 @@ package org.schabi.newpipe.settings import android.content.SharedPreferences +import android.util.Log import org.schabi.newpipe.streams.io.SharpOutputStream import org.schabi.newpipe.streams.io.StoredFileHelper import org.schabi.newpipe.util.ZipHelper @@ -13,6 +14,9 @@ import java.io.ObjectOutputStream import java.util.zip.ZipOutputStream class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) { + companion object { + const val TAG = "ContentSetManager" + } /** * Exports given [SharedPreferences] to the file in given outputPath. @@ -31,7 +35,7 @@ class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) { output.flush() } } catch (e: IOException) { - e.printStackTrace() + Log.e(TAG, "Unable to exportDatabase", e) } ZipHelper.addFileToZip(outZip, fileLocator.settings.path, "newpipe.settings") @@ -101,9 +105,9 @@ class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) { preferenceEditor.commit() } } catch (e: IOException) { - e.printStackTrace() + Log.e(TAG, "Unable to loadSharedPreferences", e) } catch (e: ClassNotFoundException) { - e.printStackTrace() + Log.e(TAG, "Unable to loadSharedPreferences", e) } } } diff --git a/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java b/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java index 8cf5a4cdf..bc4383758 100644 --- a/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java +++ b/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java @@ -14,6 +14,8 @@ import javax.net.ssl.TrustManager; import static org.schabi.newpipe.MainActivity.DEBUG; +import android.util.Log; + /** * This is an extension of the SSLSocketFactory which enables TLS 1.2 and 1.1. @@ -21,6 +23,7 @@ import static org.schabi.newpipe.MainActivity.DEBUG; */ public class TLSSocketFactoryCompat extends SSLSocketFactory { + private static final String TAG = "TLSSocketFactoryCom"; private static TLSSocketFactoryCompat instance = null; @@ -53,9 +56,7 @@ public class TLSSocketFactoryCompat extends SSLSocketFactory { try { HttpsURLConnection.setDefaultSSLSocketFactory(getInstance()); } catch (NoSuchAlgorithmException | KeyManagementException e) { - if (DEBUG) { - e.printStackTrace(); - } + Log.e(TAG, "Unable to setAsDefault", e); } }