Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Timber tree for use with Firebase Crash Reporting. Basically a copy/rewrite of Jake Wharton's CrashlyticsTree.
private static class FirebaseTree extends Timber.Tree {
@Override
protected void log(int priority, String tag, String message, Throwable t) {
if (priority == Log.VERBOSE || priority == Log.DEBUG) {
return;
}
FirebaseCrash.log(message);
if (t != null) {
FirebaseCrash.report(t);
}
}
}
@PaulWoitaschek

This comment has been minimized.

Copy link

@PaulWoitaschek PaulWoitaschek commented Dec 10, 2016

Have a look at the javadoc of timber

* @param message Formatted log message. May be {@code null}, but then {@code t} will not be.
* @param t Accompanying exceptions. May be {@code null}, but then {@code message} will not be.

So you should check for null when logging the message too.

@siergiej-jdw

This comment has been minimized.

Copy link

@siergiej-jdw siergiej-jdw commented May 13, 2020

The FirebaseCrash is deprecated. Please see the fix: https://stackoverflow.com/a/61769726/10322720

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment