Skip to content

Instantly share code, notes, and snippets.

@hanspeide
Last active October 29, 2022 23:30
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hanspeide/5387d59e316dea9f34060703cea180cb to your computer and use it in GitHub Desktop.
Save hanspeide/5387d59e316dea9f34060703cea180cb to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link

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