-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit logs non-fatal errors and warnings to Crashlytics in production.
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/src/main/java/org/selfconference/android/util/CrashlyticsTree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.selfconference.android.util; | ||
|
||
import android.util.Log; | ||
import com.crashlytics.android.Crashlytics; | ||
import com.crashlytics.android.core.CrashlyticsCore; | ||
import timber.log.Timber; | ||
|
||
public final class CrashlyticsTree extends Timber.Tree { | ||
@Override protected void log(int priority, String tag, String message, Throwable t) { | ||
CrashlyticsCore crashlyticsCore = Crashlytics.getInstance().core; | ||
|
||
crashlyticsCore.log(priority, tag, message); | ||
|
||
if (t == null) { | ||
return; | ||
} | ||
if (priority == Log.ERROR) { | ||
crashlyticsCore.logException(t); | ||
} else { | ||
crashlyticsCore.log(priority, tag, Log.getStackTraceString(t)); | ||
} | ||
} | ||
|
||
@Override protected boolean isLoggable(int priority) { | ||
return !(priority == Log.DEBUG || priority == Log.VERBOSE); | ||
} | ||
} |