Created
March 8, 2016 15:16
-
-
Save Jawnnypoo/3a2789dc333f3fd789ac to your computer and use it in GitHub Desktop.
Timber tree which prints error messages and stack traces to Crashlytics
This file contains hidden or 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
package com.example; | |
import android.util.Log; | |
import com.crashlytics.android.Crashlytics; | |
import timber.log.Timber; | |
/** | |
* {@link timber.log.Timber.Tree} which prints important messages to Crashlytics | |
* <br> | |
* | |
* @author Jawn. | |
*/ | |
public class CrashlyticsTree extends Timber.Tree { | |
@Override | |
protected void log(int priority, String tag, String message, Throwable t) { | |
if (priority == Log.VERBOSE || priority == Log.DEBUG) { | |
return; | |
} | |
Crashlytics.log(priority, tag, message); | |
if (t != null) { | |
if (priority == Log.ERROR) { | |
Crashlytics.logException(t); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment