Skip to content

Instantly share code, notes, and snippets.

Created January 18, 2017 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/5e8088dc9acd165df75bd09c0b2e2f8b to your computer and use it in GitHub Desktop.
Save anonymous/5e8088dc9acd165df75bd09c0b2e2f8b to your computer and use it in GitHub Desktop.
import android.util.Log;
import com.crashlytics.android.Crashlytics;
import timber.log.Timber;
/**
* A logging implementation which reports 'info', 'warning', and 'error' logs to Crashlytics.
*/
public final class CrashlyticsTree extends Timber.Tree {
@Override
protected boolean isLoggable(String tag, int priority) {
return priority >= Log.INFO;
}
@Override
protected void log(int priority, String tag, String message, Throwable t) {
Crashlytics.log(priority, tag, message);
if (t != null && priority == Log.ERROR) {
Crashlytics.logException(t);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment