Skip to content

Commit 1cc3d17

Browse files
committed
Incorporated Timber lib for easy logging
1 parent 4cb8563 commit 1cc3d17

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dependencies {
3030
implementation 'com.google.firebase:firebase-core:11.0.0'
3131
implementation 'com.google.firebase:firebase-auth:11.0.0'
3232
implementation 'com.google.android.gms:play-services-auth:11.0.0'
33+
implementation 'com.jakewharton.timber:timber:4.5.1'
3334
}
3435

3536
apply plugin: 'com.google.gms.google-services'

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
android:allowBackup="true"
77
android:icon="@mipmap/ic_launcher"
88
android:label="@string/app_name"
9+
android:name=".TheApp"
910
android:roundIcon="@mipmap/ic_launcher_round"
1011
android:supportsRtl="true"
1112
android:theme="@style/AppTheme">
1213
<activity android:name=".MainActivity">
1314
<intent-filter>
1415
<action android:name="android.intent.action.MAIN" />
15-
1616
<category android:name="android.intent.category.LAUNCHER" />
17+
<category android:name="android.intent.category.DEFAULT"/>
1718
</intent-filter>
1819
</activity>
1920
</application>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package in.codelab.androidauthdemo;
2+
3+
import android.util.Log;
4+
5+
import timber.log.Timber;
6+
7+
class DefaultTree extends Timber.Tree {
8+
@Override
9+
protected void log(int priority, String tag, String message, Throwable throwable) {
10+
if (priority == Log.VERBOSE || priority == Log.DEBUG) {
11+
return;
12+
}
13+
Log.println(priority, tag, message);
14+
}
15+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package in.codelab.androidauthdemo;
2+
3+
import android.app.Application;
4+
5+
import timber.log.Timber;
6+
import timber.log.Timber.DebugTree;
7+
8+
public class TheApp extends Application {
9+
@Override
10+
public void onCreate() {
11+
super.onCreate();
12+
plantingTimber();
13+
}
14+
15+
private void plantingTimber() {
16+
if (BuildConfig.DEBUG) {
17+
Timber.plant(new DebugTree());
18+
} else {
19+
//Do Nothing for now..Helpful when used with Crashlytics like tool/lib.
20+
//Ref.: https://blog.xmartlabs.com/2015/07/09/Android-logging-with-Crashlytics-and-Timber/
21+
Timber.plant(new DefaultTree());
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)