Reputation: 7100
When TestFlight crashes I have a log I wish to upload with its crash report.
Following the instructions on their website I came up with this solution, but it doesn't seem to be sending the log I pass to TFLog. However it reports the crash just fine.
-(void)applicationDidFinishLaunching:(UIApplication *)application {
/*Setup crash handlers for TestFlight so we can send logs. */
NSSetUncaughtExceptionHandler(&testFlightHandleExceptions);
// create the signal action structure
struct sigaction newSignalAction;
// initialize the signal action structure
memset(&newSignalAction, 0, sizeof(newSignalAction));
// set SignalHandler as the handler in the signal action structure
newSignalAction.sa_handler = &testFlightSignalHandler;
// set SignalHandler as the handlers for SIGABRT, SIGILL and SIGBUS
sigaction(SIGABRT, &newSignalAction, NULL);
sigaction(SIGILL, &newSignalAction, NULL);
sigaction(SIGBUS, &newSignalAction, NULL);
[TestFlight takeOff:TESTFLIGHT_API_KEY];
}
void testFlightHandleExceptions(NSException *exception) {
[LogManager e: @"Sending crash to TestFlight" Tag:@"AppDelegate"];
TFLog(@"%@",[LogManager getLog]);
}
Where have I gone wrong? Or is there a better way in doing this?
Upvotes: 1
Views: 378
Reputation: 11656
There are two problems I can see with this:
testFlightHandleExceptions
is going to be called after the crash and it's logs are recorded. Instead you need to be calling TFLog
inside of LogManager
every time you log something (before the crash). That's how it's meant to be used.
It is not ok to use objc
inside of a signal handler. For that matter, most c
isn't even allowed.
Hope that helps :)
Jason
Upvotes: 3