How to provide custom Function/Line/File information to manually invoked Crashlytics Crashes

195 views Asked by At

I have a set of custom functions that's basically wrappers to logging and assertion behaviours. In particular there is an assert class function and a fatal class function. Both which generates a log and then proceed to assert() or fatal().

In my particular case, I have Crashlytics installed. So the generated log message will also go to CLSLogv(). The assert()/fatal() then generates a Crashlytics crash report. These all work fine.

My problem is in the Crashlytics dashboard, it basically just gives me my wrapper function/file/line information as my Issue Title and Description. In essence then every single assertion event, despite of differing causes/callers, will look the same on the Crashlytics Dashboard. Invoking Crashlytics.sharedSession().crash() instead of assert()/fatal() does not help either, as crash() does not allow any arguments for function/line/file.

Is there any other ways of doing this? Or is this essentially an enhancement request to Crashlytics/Fabric/Google? Thanks!

1

There are 1 answers

2
nyg On

Swift allows you to use these special values: #file, #function, #line and #column. Using them with CLSLogv() may help you find the exact places your code went through:

CLSLogv("I was here: %@.%@, %i:%i", getVaList([ #file, #function, #line, #column ]))

Result in Crashlytics dashboard:

1 | 2017-09-05T08:32:22.088Z | I was here: /Users/.../SettingsTableViewController.swift.viewDidLoad(), 27:82

Hope this helps :).