Skip to content

Instantly share code, notes, and snippets.

@gandharva
Last active August 29, 2015 13:58
Show Gist options
  • Select an option

  • Save gandharva/10385911 to your computer and use it in GitHub Desktop.

Select an option

Save gandharva/10385911 to your computer and use it in GitHub Desktop.
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