Skip to content

Commit

Permalink
🤝 Merge pull request #71 from Instabug/hotfix/fix_crash_for_ios_8
Browse files Browse the repository at this point in the history
🐛 Fix a bug where the app crashes on iOS 8 due to os_logs.
  • Loading branch information
salmatarzi authored Sep 10, 2017
2 parents 851b51f + 6db813a commit f01be83
Showing 1 changed file with 5 additions and 43 deletions.
48 changes: 5 additions & 43 deletions ios/RNInstabug/InstabugReactBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -450,50 +450,12 @@ + (BOOL)iOSVersionIsLessThan:(NSString *)iOSVersion {
NSString *message
)
{
NSString *log = RCTFormatLog([NSDate date], level, fileName, lineNumber, message);


NSLog(@"Instabug - REACT LOG: %s", log.UTF8String);
NSString *log = RCTFormatLog([NSDate date], level, fileName, lineNumber, message);
NSString *compeleteLog = [NSString stringWithFormat:@"Instabug - REACT LOG: %@", log];

if([InstabugReactBridge iOSVersionIsLessThan:@"10.0"]) {
int aslLevel;
switch(level) {
case RCTLogLevelTrace:
aslLevel = ASL_LEVEL_DEBUG;
break;
case RCTLogLevelInfo:
aslLevel = ASL_LEVEL_NOTICE;
break;
case RCTLogLevelWarning:
aslLevel = ASL_LEVEL_WARNING;
break;
case RCTLogLevelError:
aslLevel = ASL_LEVEL_ERR;
break;
case RCTLogLevelFatal:
aslLevel = ASL_LEVEL_CRIT;
break;
}
asl_log(NULL, NULL, aslLevel, "%s", message.UTF8String);
} else {
switch(level) {
case RCTLogLevelTrace:
os_log(OS_LOG_DEFAULT, "%s", [message UTF8String]);
break;
case RCTLogLevelInfo:
os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_INFO, "%s", [message UTF8String]);
break;
case RCTLogLevelWarning:
os_log(OS_LOG_DEFAULT, "%s", [message UTF8String]);
break;
case RCTLogLevelError:
os_log_error(OS_LOG_DEFAULT, "%s", [message UTF8String]);
break;
case RCTLogLevelFatal:
os_log_fault(OS_LOG_DEFAULT, "%s", [message UTF8String]);
break;
}
}
va_list arg_list;

IBGNSLog(compeleteLog, arg_list);
};

@end

0 comments on commit f01be83

Please sign in to comment.