Skip to content

Instantly share code, notes, and snippets.

@kalyaganov
Created December 27, 2018 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalyaganov/1804ea4804e674d71c4da08350c7d173 to your computer and use it in GitHub Desktop.
Save kalyaganov/1804ea4804e674d71c4da08350c7d173 to your computer and use it in GitHub Desktop.
/**
* A tree which logs important information for crash reporting.
*/
private class CrashReportingTree : Timber.Tree() {
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
if (priority == Log.VERBOSE || priority == Log.DEBUG) {
return
}
Crashlytics.log(priority, tag, message)
if (t != null) {
if (priority == Log.ERROR) {
Crashlytics.logException(t)
} else if (priority == Log.WARN) {
Crashlytics.logException(t)
}
}
}
}
Fabric.with(this, Crashlytics())
Timber.plant(CrashReportingTree())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment