🐛 Fix a bug where the app crashes on iOS 8 due to os_logs.

This commit is contained in:
Salma ElTarzi 2017-09-07 19:49:10 +02:00
parent 720581c90b
commit b05ce5aa5a

View File

@ -450,11 +450,12 @@ RCTLogFunction InstabugReactLogFunction = ^(
NSString *message NSString *message
) )
{ {
NSString *log = RCTFormatLog([NSDate date], level, fileName, lineNumber, message); NSString *log = RCTFormatLog([NSDate date], level, fileName, lineNumber, message);
NSString *compeleteLog = [NSString stringWithFormat:@"Instabug - REACT LOG: %@", log];
NSLog(@"Instabug - REACT LOG: %s", log.UTF8String);
va_list arg_list;
IBGNSLog(compeleteLog, arg_list);
if([InstabugReactBridge iOSVersionIsLessThan:@"10.0"]) { if([InstabugReactBridge iOSVersionIsLessThan:@"10.0"]) {
int aslLevel; int aslLevel;
switch(level) { switch(level) {
@ -474,23 +475,25 @@ RCTLogFunction InstabugReactLogFunction = ^(
aslLevel = ASL_LEVEL_CRIT; aslLevel = ASL_LEVEL_CRIT;
break; break;
} }
asl_log(NULL, NULL, aslLevel, "%s", message.UTF8String); asl_log(NULL, NULL, aslLevel, "%s", log.UTF8String);
} else { } else {
os_log_t newlog = os_log_create("Default", "Instabug");
switch(level) { switch(level) {
case RCTLogLevelTrace: case RCTLogLevelTrace:
os_log(OS_LOG_DEFAULT, "%s", [message UTF8String]); os_log(newlog, "%s", [message UTF8String]);
break; break;
case RCTLogLevelInfo: case RCTLogLevelInfo:
os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_INFO, "%s", [message UTF8String]); os_log_with_type(newlog, OS_LOG_TYPE_INFO, "%s", [message UTF8String]);
break; break;
case RCTLogLevelWarning: case RCTLogLevelWarning:
os_log(OS_LOG_DEFAULT, "%s", [message UTF8String]); os_log(newlog, "%s", [message UTF8String]);
break; break;
case RCTLogLevelError: case RCTLogLevelError:
os_log_error(OS_LOG_DEFAULT, "%s", [message UTF8String]); os_log_error(newlog, "%s", [message UTF8String]);
break; break;
case RCTLogLevelFatal: case RCTLogLevelFatal:
os_log_fault(OS_LOG_DEFAULT, "%s", [message UTF8String]); os_log_fault(newlog, "%s", [message UTF8String]);
break; break;
} }
} }