From 7db93a376bc81bbda7f6a535e80cd7ca8b0ec3ca Mon Sep 17 00:00:00 2001 From: Ben Nham Date: Wed, 31 Aug 2016 11:24:34 -0700 Subject: [PATCH] configure glog sink for custom jsc Reviewed By: alexeylang Differential Revision: D3789493 fbshipit-source-id: b3ecbd1caddfeef5e948e43444be95207c573f67 --- React/Executors/RCTJSCWrapper.mm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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)