From b05ce5aa5aae5f02f3d541ac897bb1cd5cd56057 Mon Sep 17 00:00:00 2001 From: Salma ElTarzi Date: Thu, 7 Sep 2017 19:49:10 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20a=20bug=20where=20the?= =?UTF-8?q?=20app=20crashes=20on=20iOS=208=20due=20to=20os=5Flogs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/RNInstabug/InstabugReactBridge.m | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index cee604368..3c007582b 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -450,11 +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]; + + va_list arg_list; + IBGNSLog(compeleteLog, arg_list); if([InstabugReactBridge iOSVersionIsLessThan:@"10.0"]) { int aslLevel; switch(level) { @@ -474,23 +475,25 @@ + (BOOL)iOSVersionIsLessThan:(NSString *)iOSVersion { aslLevel = ASL_LEVEL_CRIT; break; } - asl_log(NULL, NULL, aslLevel, "%s", message.UTF8String); + asl_log(NULL, NULL, aslLevel, "%s", log.UTF8String); } else { + os_log_t newlog = os_log_create("Default", "Instabug"); + switch(level) { case RCTLogLevelTrace: - os_log(OS_LOG_DEFAULT, "%s", [message UTF8String]); + os_log(newlog, "%s", [message UTF8String]); break; 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; case RCTLogLevelWarning: - os_log(OS_LOG_DEFAULT, "%s", [message UTF8String]); + os_log(newlog, "%s", [message UTF8String]); break; case RCTLogLevelError: - os_log_error(OS_LOG_DEFAULT, "%s", [message UTF8String]); + os_log_error(newlog, "%s", [message UTF8String]); break; case RCTLogLevelFatal: - os_log_fault(OS_LOG_DEFAULT, "%s", [message UTF8String]); + os_log_fault(newlog, "%s", [message UTF8String]); break; } } From 0f43c93b5f1510939763b84541a1ce0dcb9b6228 Mon Sep 17 00:00:00 2001 From: Salma ElTarzi Date: Sun, 10 Sep 2017 13:13:01 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A5=20Remove=20redundant=20code=20?= =?UTF-8?q?for=20iOS=20log=20levels.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/RNInstabug/InstabugReactBridge.m | 41 ---------------------------- 1 file changed, 41 deletions(-) diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index 3c007582b..72e936356 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -456,47 +456,6 @@ + (BOOL)iOSVersionIsLessThan:(NSString *)iOSVersion { va_list arg_list; IBGNSLog(compeleteLog, arg_list); - 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", log.UTF8String); - } else { - os_log_t newlog = os_log_create("Default", "Instabug"); - - switch(level) { - case RCTLogLevelTrace: - os_log(newlog, "%s", [message UTF8String]); - break; - case RCTLogLevelInfo: - os_log_with_type(newlog, OS_LOG_TYPE_INFO, "%s", [message UTF8String]); - break; - case RCTLogLevelWarning: - os_log(newlog, "%s", [message UTF8String]); - break; - case RCTLogLevelError: - os_log_error(newlog, "%s", [message UTF8String]); - break; - case RCTLogLevelFatal: - os_log_fault(newlog, "%s", [message UTF8String]); - break; - } - } }; @end