Skip to content

Commit 272be36

Browse files
committed
Removed e.printStacktrace and used an proper logger
1 parent b5ad24e commit 272be36

4 files changed

Lines changed: 15 additions & 10 deletions

File tree

app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import android.content.Intent
2525
import android.content.SharedPreferences
2626
import android.os.Bundle
2727
import android.os.Parcelable
28+
import android.util.Log
2829
import android.view.LayoutInflater
2930
import android.view.Menu
3031
import android.view.MenuInflater
@@ -464,7 +465,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
464465
errors.subList(i + 1, errors.size)
465466
)
466467
},
467-
{ throwable -> throwable.printStackTrace() }
468+
{ throwable -> Log.e(TAG, "Unable to process", throwable) }
468469
)
469470
return // this will be called on the remaining errors by handleFeedNotAvailable()
470471
}

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ && isPlaybackResumeEnabled(this)
695695
},
696696
error -> {
697697
if (DEBUG) {
698-
error.printStackTrace();
698+
Log.w(TAG, "Failed to start playback", error);
699699
}
700700
// In case any error we can start playback without history
701701
initPlayback(newQueue, repeatMode, playbackSpeed, playbackPitch,
@@ -4184,8 +4184,7 @@ private boolean isLive() {
41844184
} catch (@NonNull final IndexOutOfBoundsException e) {
41854185
// Why would this even happen =(... but lets log it anyway, better safe than sorry
41864186
if (DEBUG) {
4187-
Log.d(TAG, "player.isCurrentWindowDynamic() failed: " + e.getMessage());
4188-
e.printStackTrace();
4187+
Log.d(TAG, "player.isCurrentWindowDynamic() failed: ", e);
41894188
}
41904189
return false;
41914190
}

app/src/main/java/org/schabi/newpipe/settings/ContentSettingsManager.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.schabi.newpipe.settings
22

33
import android.content.SharedPreferences
4+
import android.util.Log
45
import org.schabi.newpipe.streams.io.SharpOutputStream
56
import org.schabi.newpipe.streams.io.StoredFileHelper
67
import org.schabi.newpipe.util.ZipHelper
@@ -13,6 +14,9 @@ import java.io.ObjectOutputStream
1314
import java.util.zip.ZipOutputStream
1415

1516
class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) {
17+
companion object {
18+
const val TAG = "ContentSetManager"
19+
}
1620

1721
/**
1822
* Exports given [SharedPreferences] to the file in given outputPath.
@@ -31,7 +35,7 @@ class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) {
3135
output.flush()
3236
}
3337
} catch (e: IOException) {
34-
e.printStackTrace()
38+
Log.e(TAG, "Unable to exportDatabase", e)
3539
}
3640

3741
ZipHelper.addFileToZip(outZip, fileLocator.settings.path, "newpipe.settings")
@@ -101,9 +105,9 @@ class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) {
101105
preferenceEditor.commit()
102106
}
103107
} catch (e: IOException) {
104-
e.printStackTrace()
108+
Log.e(TAG, "Unable to loadSharedPreferences", e)
105109
} catch (e: ClassNotFoundException) {
106-
e.printStackTrace()
110+
Log.e(TAG, "Unable to loadSharedPreferences", e)
107111
}
108112
}
109113
}

app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414

1515
import static org.schabi.newpipe.MainActivity.DEBUG;
1616

17+
import android.util.Log;
18+
1719

1820
/**
1921
* This is an extension of the SSLSocketFactory which enables TLS 1.2 and 1.1.
2022
* Created for usage on Android 4.1-4.4 devices, which haven't enabled those by default.
2123
*/
2224
public class TLSSocketFactoryCompat extends SSLSocketFactory {
2325

26+
private static final String TAG = "TLSSocketFactoryCom";
2427

2528
private static TLSSocketFactoryCompat instance = null;
2629

@@ -53,9 +56,7 @@ public static void setAsDefault() {
5356
try {
5457
HttpsURLConnection.setDefaultSSLSocketFactory(getInstance());
5558
} catch (NoSuchAlgorithmException | KeyManagementException e) {
56-
if (DEBUG) {
57-
e.printStackTrace();
58-
}
59+
Log.e(TAG, "Unable to setAsDefault", e);
5960
}
6061
}
6162

0 commit comments

Comments
 (0)