Permalink
Browse files

configure glog sink for custom jsc

Reviewed By: alexeylang

Differential Revision: D3789493

fbshipit-source-id: b3ecbd1caddfeef5e948e43444be95207c573f67
  • Loading branch information...
1 parent 6897f40 commit 7db93a376bc81bbda7f6a535e80cd7ca8b0ec3ca @bnham bnham committed with Facebook Github Bot 9 Aug 31, 2016
Showing with 18 additions and 0 deletions.
  1. +18 −0 React/Executors/RCTJSCWrapper.mm
@@ -16,6 +16,12 @@
#include <dlfcn.h>
+#if HAS_FBGLOG
+#import <FBGLog/FBGLogSink.h>
+
+typedef void (*configureJSCLoggingForIOSFuncType)(int32_t, std::unique_ptr<google::LogSink>, 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)

0 comments on commit 7db93a3

Please sign in to comment.