java Android / Timber / Crashlytics树发送生成日志

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java Android / Timber / Crashlytics树发送生成日志相关的知识,希望对你有一定的参考价值。

public class CrashlyticsTree extends Timber.Tree {
  public CrashlyticsTree(Context context, DeviceInfo deviceInfo) {
    Fabric.with(context, new Crashlytics());

    // Put some debug variables for every crash
    // CrashlyticsCore core = Crashlytics.getInstance().core;
    // core.setString("Git SHA", BuildConfig.GIT_SHA);
  }

  @Override
  protected void log(int priority, String tag, String message, Throwable t) {
    if (priority == Log.VERBOSE && !"release".equals(BuildConfig.BUILD_TYPE)) {
      //Dont log verbose messages and avoid not release builds to send crash to crashlytics
      return;
    }

    CrashlyticsCore core = Crashlytics.getInstance().core;
    core.log(Log.ERROR, tag, message);

    if (t != null && priority == Log.ERROR) {
      core.logException(t);
    }
  }
}
public class SkempiApp extends Application {

  @Override
  public void onCreate() {
    super.onCreate();

    if (BuildConfig.DEBUG) {
      Timber.plant(new Timber.DebugTree());
    } else {
      Timber.plant(new CrashlyticsTree(this, new DeviceInfo(this)));
    }
  }
}

以上是关于java Android / Timber / Crashlytics树发送生成日志的主要内容,如果未能解决你的问题,请参考以下文章

java Android / Timber / Crashlytics树发送生成日志

java Android / Timber / Crashlytics树发送生成日志

java Android / Timber / Crashlytics树发送生成日志

java Android / Timber / Crashlytics树发送生成日志

java Android / Timber / Crashlytics树发送生成日志

java Android / Timber / Crashlytics树发送生成日志