Skip to content

Commit

Permalink
refactor: Log with Timber (#218)
Browse files Browse the repository at this point in the history
Use Timber instead of `android.util.Log`. Removes the need for `TAG`
statics in companion objects, slightly simplifying the code. Opens the
door for some production logging in the future.
  • Loading branch information
nikclayton authored Nov 4, 2023
1 parent 6aa4eab commit f887790
Show file tree
Hide file tree
Showing 93 changed files with 329 additions and 480 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ dependencies {
implementation libs.bundles.xmldiff

implementation libs.bundles.aboutlibraries
implementation libs.timber

testImplementation libs.androidx.test.junit
testImplementation libs.robolectric
Expand Down
68 changes: 34 additions & 34 deletions app/lint-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2929,7 +2929,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/components/login/LoginActivity.kt"
line="155"
line="156"
column="22"/>
</issue>

Expand Down Expand Up @@ -3094,7 +3094,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="557"
line="556"
column="17"/>
</issue>

Expand All @@ -3105,7 +3105,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="560"
line="559"
column="21"/>
</issue>

Expand All @@ -3116,7 +3116,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="565"
line="564"
column="17"/>
</issue>

Expand All @@ -3127,7 +3127,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="569"
line="568"
column="21"/>
</issue>

Expand All @@ -3138,7 +3138,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="574"
line="573"
column="17"/>
</issue>

Expand All @@ -3149,7 +3149,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="577"
line="576"
column="21"/>
</issue>

Expand All @@ -3160,7 +3160,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="582"
line="581"
column="17"/>
</issue>

Expand All @@ -3171,7 +3171,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="585"
line="584"
column="21"/>
</issue>

Expand All @@ -3182,7 +3182,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="590"
line="589"
column="17"/>
</issue>

Expand All @@ -3193,7 +3193,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="593"
line="592"
column="21"/>
</issue>

Expand All @@ -3204,7 +3204,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="597"
line="596"
column="17"/>
</issue>

Expand All @@ -3215,7 +3215,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="600"
line="599"
column="21"/>
</issue>

Expand All @@ -3226,7 +3226,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="605"
line="604"
column="17"/>
</issue>

Expand All @@ -3237,7 +3237,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="608"
line="607"
column="21"/>
</issue>

Expand All @@ -3248,7 +3248,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="612"
line="611"
column="17"/>
</issue>

Expand All @@ -3259,7 +3259,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="616"
line="615"
column="21"/>
</issue>

Expand All @@ -3270,7 +3270,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="625"
line="624"
column="17"/>
</issue>

Expand All @@ -3281,7 +3281,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="628"
line="627"
column="21"/>
</issue>

Expand All @@ -3292,7 +3292,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="633"
line="632"
column="17"/>
</issue>

Expand All @@ -3303,7 +3303,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="636"
line="635"
column="21"/>
</issue>

Expand All @@ -3314,7 +3314,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="641"
line="640"
column="17"/>
</issue>

Expand All @@ -3325,7 +3325,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="644"
line="643"
column="21"/>
</issue>

Expand All @@ -3336,7 +3336,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="649"
line="648"
column="17"/>
</issue>

Expand All @@ -3347,7 +3347,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="652"
line="651"
column="21"/>
</issue>

Expand All @@ -3358,7 +3358,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="659"
line="658"
column="21"/>
</issue>

Expand All @@ -3369,7 +3369,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="662"
line="661"
column="25"/>
</issue>

Expand All @@ -3380,7 +3380,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="671"
line="670"
column="17"/>
</issue>

Expand All @@ -3391,7 +3391,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="674"
line="673"
column="21"/>
</issue>

Expand All @@ -3402,7 +3402,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="687"
line="686"
column="17"/>
</issue>

Expand All @@ -3413,7 +3413,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="691"
line="690"
column="21"/>
</issue>

Expand All @@ -3424,7 +3424,7 @@
errorLine2=" ~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="812"
line="811"
column="17"/>
</issue>

Expand All @@ -3435,7 +3435,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="814"
line="813"
column="17"/>
</issue>

Expand All @@ -3446,7 +3446,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/pachli/MainActivity.kt"
line="825"
line="824"
column="17"/>
</issue>

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/app/pachli/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;

Expand Down Expand Up @@ -66,6 +65,7 @@
import dagger.hilt.android.AndroidEntryPoint;
import dagger.hilt.android.EntryPointAccessors;
import dagger.hilt.components.SingletonComponent;
import timber.log.Timber;

@AndroidEntryPoint
public abstract class BaseActivity extends AppCompatActivity {
Expand Down Expand Up @@ -96,7 +96,7 @@ public void setTheme(int themeId) {
super.setTheme(themeId);
if (BuildConfig.DEBUG) {
String name = getResources().getResourceEntryName(themeId);
Log.d(TAG, "Setting theme: " + name);
Timber.d("Setting theme: %s", name);
}
}

Expand All @@ -108,7 +108,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
* runtime, just individual activities. So, each activity has to set its theme before any
* views are created. */
String theme = sharedPreferencesRepository.getString(APP_THEME, ThemeUtils.APP_THEME_DEFAULT);
Log.d("activeTheme", theme);
Timber.d("activeTheme: %s", theme);
if (theme.equals(THEME_BLACK)) {
setTheme(R.style.Theme_Pachli_Black);
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/app/pachli/EditProfileActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import android.graphics.Bitmap
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.view.View
Expand Down Expand Up @@ -59,6 +58,7 @@ import com.mikepenz.iconics.utils.colorInt
import com.mikepenz.iconics.utils.sizeDp
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import timber.log.Timber

@AndroidEntryPoint
class EditProfileActivity : BaseActivity() {
Expand Down Expand Up @@ -315,7 +315,7 @@ class EditProfileActivity : BaseActivity() {
}

private fun onPickFailure(throwable: Throwable?) {
Log.w("EditProfileActivity", "failed to pick media", throwable)
Timber.w("failed to pick media", throwable)
Snackbar.make(binding.avatarButton, R.string.error_media_upload_sending, Snackbar.LENGTH_LONG).show()
}

Expand Down
Loading

0 comments on commit f887790

Please sign in to comment.