2

I want to use Crashlytics.setInt(KEY, val) to see the value a variable had at the time of the crash.
I wish to avoid calling the method every time the value changes.
I have more than one thing in mind, but among them, logging of time since starting a resource-intensive task (e.g. video streaming).

I suppose this could be done with a custom UncaughtExceptionhandler, but is there a cleaner way?

[edit] if it wasn't clear, I want this to happen:

  1. Crash occurs
  2. Crashlytics.setLong(TIME_SINCE_XYZ_STARTED, System.currentTimeMillis() - startTimeOfXyz); Crashlytics.setString(XYZ_STATE, xyz.connState); Crashlytics.setInt(XYZ_QUEUE_LENGTH, xyz.queue.size())
  3. Crashlytics compiles crash report

The problem being that I can perform step 2 at any time, but I want it to be triggered by the crash.

kaay
  • 1,083
  • 1
  • 12
  • 31
  • Ok, so it seems that, unless Crashlytics has changed this in the 2 years since the other question, the answer is "custom UncaughtExceptionHandler", after all. – kaay Mar 05 '19 at 09:00

1 Answers1

-1

Did you try to use Crashlytics.log(Log.INFO, yourKey, yourData); ?

  • Not what I want, for 2 reasons: 1. I want to use a custom key to see the last value, not spam the (size-limited) log chronicling every change. 2. The main point of the question is how to perform the action - whether log, or set* - between the crash occurrance and crashlytics crash log compilation. – kaay Mar 04 '19 at 13:59
  • Keep the last value before you use it, and if exceptionHandler is called, log the last value you keeped – Christos Themelis Mar 04 '19 at 14:09
  • This is in the question: "I suppose this could be done with a custom UncaughtExceptionhandler, but is there a cleaner way?" – kaay Mar 04 '19 at 14:13
  • I suppose that your code is in try - catch to prevent app crash, and at the catch part you create a firebase log. – Christos Themelis Mar 04 '19 at 14:23