问题
I have a situation where I want to add some logs to Crashlystic for Android, but not always send it. Then before coming back to the same function I want to clear the log. For this I can't seem to find how to do this. Below is an illustration of the situation:
public foo() {
bar();
bar();
bar();
}
public bar() {
// Clear log here, but I don't know how
...
// Add new log here.
Crashlytics.log(1, "TAG", "log information");
Crashlytics.log(1, "TAG", "log information");
Crashlytics.log(1, "TAG", "log information");
if (condition) {
Crashlytics.logException(new Exception("Throwing the actual non fatal error to log"));
}
}
The problem is that when not clearing the log, the next actual non-fatal crash will have all the logging for all the times it was not intended to be send. I will need just the logs of the last time bar()
was called.
回答1:
Mike from Fabric here.
With Crashlytics' logs that functionality isn't an option. You can use [custom keys] (https://docs.fabric.io/android/crashlytics/enhanced-reports.html#custom-keys) and then you can set the value to nil or empty to reset the value.
来源:https://stackoverflow.com/questions/42255778/crashlyticsandroid-clear-log-before-next-crash