如何使用Couchdb配置CUSTOM_DATA字段?
我想设置一个配置值与错误一起发送。在后端,我有一个带有ACLARYZER Web应用程序的沙发数据库。
这是我在Android的Application.class上定义此自定义数据值的代码。
@ReportsCrashes( formUri = "https://user.cloudant.com/acra-report/_design/acra-storage/_update/report", reportType = HttpSender.Type.JSON, httpMethod = HttpSender.Method.POST, formUriBasicAuthLogin = "user", formUriBasicAuthPassword = "pass", formKey = "", // This is required for backward compatibility but not used customReportContent = { ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, ReportField.ANDROID_VERSION, ReportField.PACKAGE_NAME, ReportField.REPORT_ID, ReportField.BUILD, ReportField.STACK_TRACE, ReportField.CUSTOM_DATA }, mode = ReportingInteractionMode.TOAST, resToastText = R.string.reporte_error ) public class my_applicaction extends Application{ @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); ACRA.init(my_applicaction.this); ACRA.getErrorReporter().putCustomData("myKey", "myValue"); ACRA.getErrorReporter().handleException(null); } }
现在的问题是如何在沙发数据库中添加值以获取此自定义数据字段。还是我必须在ACRALYZER中定义自定义数据?
谢谢?
最后,这比我想象的要容易。
只需在每条CUSTOM_DATA中添加这一行
ACRA.getErrorReporter().putCustomData("NAME_VALUE1", "VALUE1");
然后您的代码就是这样。
@Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); ACRA.init(Application.this); ACRA.getErrorReporter().putCustomData("NAME_VALUE1", "VALUE1"); ACRA.getErrorReporter().putCustomData("NAME_VALUE2", "VALUE2"); ACRA.getErrorReporter().putCustomData("NAME_VALUE3", "VALUE3"); }
ACLARYZER负责其余的工作。