记录日志时DebugTree
,我看到类名,但是当我创建自定义树时,标签是null
. 这是我的自定义树的样子:
public class CrashlyticsTree extends Timber.Tree {
private static final String CRASHLYTICS_KEY_PRIORITY = "priority";
private static final String CRASHLYTICS_KEY_TAG = "tag";
private static final String CRASHLYTICS_KEY_MESSAGE = "message";
@Override
protected boolean isLoggable(int priority) {
if (priority == Log.VERBOSE || priority == Log.DEBUG || priority == Log.INFO) {
return false;
}
// only log WARN(Timber.w), ERROR(Timber.e), or WTF(Timber.wtf)
return true;
}
@Override
protected void log(int priority, @Nullable String tag, @Nullable String message, @Nullable Throwable t) {
if(User.CurrentUser.isLoggedIn()){
Crashlytics.setUserIdentifier(Long.toString(User.CurrentUser.getUserId()));
}
Crashlytics.setInt(CRASHLYTICS_KEY_PRIORITY, priority);
Crashlytics.setString(CRASHLYTICS_KEY_TAG, tag);
Crashlytics.setString(CRASHLYTICS_KEY_MESSAGE, message);
if (t == null) {
Crashlytics.logException(new Exception(message));
} else {
if(!TextUtils.isEmpty(message)){
Crashlytics.log(priority, tag, message);
}
Crashlytics.logException(t);
}
}
}
然而,即使来自 DebugTree,生成的标记也是BaseActivity
因为它确实来自BaseActivity
但是我想知道是否有一种方法可以获得扩展 BaseActivity 的类的名称