@@ -442,6 +442,15 @@ + (BOOL)iOSVersionIsLessThan:(NSString *)iOSVersion {
442442 return [iOSVersion compare: [UIDevice currentDevice ].systemVersion options: NSNumericSearch] == NSOrderedDescending;
443443};
444444
445+ // Note: This function is used to bridge IBGNSLog with RCTLogFunction.
446+ // This log function should not be used externally and is only an implementation detail.
447+ void RNIBGLog (IBGLogLevel logLevel, NSString *format, ...) {
448+ va_list arg_list;
449+ va_start (arg_list, format);
450+ IBGNSLogWithLevel (format, arg_list, logLevel);
451+ va_end (arg_list);
452+ }
453+
445454RCTLogFunction InstabugReactLogFunction = ^(
446455 RCTLogLevel level,
447456 __unused RCTLogSource source,
@@ -450,30 +459,27 @@ + (BOOL)iOSVersionIsLessThan:(NSString *)iOSVersion {
450459 NSString *message
451460 )
452461{
462+ NSString *formatString = @" Instabug - REACT LOG: %@ " ;
453463 NSString *log = RCTFormatLog ([NSDate date ], level, fileName, lineNumber, message);
454- NSString *compeleteLog = [NSString stringWithFormat: @" Instabug - REACT LOG: %@ " , log];
455-
456- dispatch_async (dispatch_get_main_queue (), ^{
457- va_list arg_list;
458-
459- switch (level) {
460- case RCTLogLevelTrace:
461- IBGNSLogWithLevel (compeleteLog, arg_list, IBGLogLevelTrace);
462- break ;
463- case RCTLogLevelInfo:
464- IBGNSLogWithLevel (compeleteLog, arg_list, IBGLogLevelInfo);
465- break ;
466- case RCTLogLevelWarning:
467- IBGNSLogWithLevel (compeleteLog, arg_list, IBGLogLevelWarning);
468- break ;
469- case RCTLogLevelError:
470- IBGNSLogWithLevel (compeleteLog, arg_list, IBGLogLevelError);
471- break ;
472- case RCTLogLevelFatal:
473- IBGNSLogWithLevel (compeleteLog, arg_list, IBGLogLevelFatal);
474- break ;
475- }
476- });
464+
465+ switch (level) {
466+ case RCTLogLevelTrace:
467+ RNIBGLog (IBGLogLevelTrace, formatString, log);
468+ break ;
469+ case RCTLogLevelInfo:
470+ RNIBGLog (IBGLogLevelInfo, formatString, log);
471+ break ;
472+ case RCTLogLevelWarning:
473+ RNIBGLog (IBGLogLevelWarning, formatString, log);
474+ break ;
475+ case RCTLogLevelError:
476+ RNIBGLog (IBGLogLevelError, formatString, log);
477+ break ;
478+ case RCTLogLevelFatal:
479+ RNIBGLog (IBGLogLevelFatal, formatString, log);
480+ break ;
481+ }
477482};
478483
484+
479485@end
0 commit comments