diff --git a/React/Executors/RCTJSCWrapper.mm b/React/Executors/RCTJSCWrapper.mm index ceaf89af71a..0a736df2b2f 100644 --- a/React/Executors/RCTJSCWrapper.mm +++ b/React/Executors/RCTJSCWrapper.mm @@ -16,6 +16,12 @@ #include +#if HAS_FBGLOG +#import + +typedef void (*configureJSCLoggingForIOSFuncType)(int32_t, std::unique_ptr, void (*)()); +#endif + static void *RCTCustomLibraryHandler(void) { static dispatch_once_t token; @@ -88,6 +94,18 @@ static void RCTSetUpCustomLibraryPointers(RCTJSCWrapper *wrapper) wrapper->JSContext = (__bridge Class)dlsym(libraryHandle, "OBJC_CLASS_$_JSContext"); wrapper->JSValue = (__bridge Class)dlsym(libraryHandle, "OBJC_CLASS_$_JSValue"); wrapper->configureJSContextForIOS = (configureJSContextForIOSFuncType)dlsym(libraryHandle, "configureJSContextForIOS"); + +#if HAS_FBGLOG + static dispatch_once_t once; + dispatch_once(&once, ^{ + void *handle = dlsym(libraryHandle, "configureJSCLoggingForIOS"); + + if (handle) { + configureJSCLoggingForIOSFuncType logConfigFunc = (configureJSCLoggingForIOSFuncType)handle; + logConfigFunc(google::GLOG_INFO, FBGLogSink(), FBGLogFailureFunction); + } + }); +#endif } RCTJSCWrapper *RCTJSCWrapperCreate(BOOL useCustomJSC)