Skip to content

Instantly share code, notes, and snippets.

@Jawnnypoo
Created March 8, 2016 15:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jawnnypoo/3a2789dc333f3fd789ac to your computer and use it in GitHub Desktop.
Save Jawnnypoo/3a2789dc333f3fd789ac to your computer and use it in GitHub Desktop.
Timber tree which prints error messages and stack traces to Crashlytics
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