Last active
August 29, 2015 13:58
-
-
Save gandharva/10385911 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.leftshift.app; | |
| import com.crashlytics.android.Crashlytics; | |
| import timber.log.Timber; | |
| /** | |
| * A logging implementation which reports 'info', 'warning', and 'error' logs to Crashlytics. | |
| */ | |
| public class CrashlyticsTree extends Timber.HollowTree { | |
| @Override public void v(String message, Object... args) { | |
| logMessage(message, args); | |
| } | |
| @Override public void v(Throwable t, String message, Object... args) { | |
| logMessage(message, args); | |
| // NOTE: We are explicitly not sending the exception to Crashlytics here. | |
| } | |
| @Override public void i(String message, Object... args) { | |
| logMessage(message, args); | |
| } | |
| @Override public void i(Throwable t, String message, Object... args) { | |
| logMessage(message, args); | |
| // NOTE: We are explicitly not sending the exception to Crashlytics here. | |
| } | |
| @Override public void w(String message, Object... args) { | |
| logMessage("WARN: " + message, args); | |
| } | |
| @Override public void w(Throwable t, String message, Object... args) { | |
| logMessage("WARN: " + message, args); | |
| // NOTE: We are explicitly not sending the exception to Crashlytics here. | |
| } | |
| @Override public void e(String message, Object... args) { | |
| logMessage("ERROR: " + message, args); | |
| } | |
| @Override public void e(Throwable t, String message, Object... args) { | |
| logMessage("ERROR: " + message, args); | |
| Crashlytics.logException(t); | |
| } | |
| private void logMessage(String message, Object... args) { | |
| Crashlytics.log(String.format(message, args)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment