Skip to content

Commit

Permalink
configure glog sink for custom jsc
Browse files Browse the repository at this point in the history
Reviewed By: alexeylang

Differential Revision: D3789493

fbshipit-source-id: b3ecbd1caddfeef5e948e43444be95207c573f67
  • Loading branch information
bnham authored and Facebook Github Bot 9 committed Aug 31, 2016
1 parent 6897f40 commit 7db93a3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions React/Executors/RCTJSCWrapper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7db93a3

Please sign in to comment.