Skip to content

Commit

Permalink
Guard all debug logs behind an MC
Browse files Browse the repository at this point in the history
Reviewed By: PeteTheHeat

Differential Revision: D21292280

fbshipit-source-id: 1701a945f126f35a53417b57e3162372d39e75f1
  • Loading branch information
RSNara authored and facebook-github-bot committed Apr 29, 2020
1 parent 3fb37b4 commit 97bc084
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1252,32 +1252,38 @@ private ReactApplicationContext createReactContext(

reactContext.initializeWithInstance(catalystInstance);

// TODO(T46487253): Remove after task is closed
FLog.e(
ReactConstants.TAG,
"ReactInstanceManager.createReactContext: mJSIModulePackage "
+ (mJSIModulePackage != null ? "not null" : "null"));
if (ReactFeatureFlags.enableTurboModuleDebugLogs) {
// TODO(T46487253): Remove after task is closed
FLog.e(
ReactConstants.TAG,
"ReactInstanceManager.createReactContext: mJSIModulePackage "
+ (mJSIModulePackage != null ? "not null" : "null"));
}

if (mJSIModulePackage != null) {
catalystInstance.addJSIModules(
mJSIModulePackage.getJSIModules(
reactContext, catalystInstance.getJavaScriptContextHolder()));

// TODO(T46487253): Remove after task is closed
FLog.e(
ReactConstants.TAG,
"ReactInstanceManager.createReactContext: ReactFeatureFlags.useTurboModules == "
+ (ReactFeatureFlags.useTurboModules == false ? "false" : "true"));
if (ReactFeatureFlags.enableTurboModuleDebugLogs) {
// TODO(T46487253): Remove after task is closed
FLog.e(
ReactConstants.TAG,
"ReactInstanceManager.createReactContext: ReactFeatureFlags.useTurboModules == "
+ (ReactFeatureFlags.useTurboModules == false ? "false" : "true"));
}

if (ReactFeatureFlags.useTurboModules) {
JSIModule turboModuleManager =
catalystInstance.getJSIModule(JSIModuleType.TurboModuleManager);

// TODO(T46487253): Remove after task is closed
FLog.e(
ReactConstants.TAG,
"ReactInstanceManager.createReactContext: TurboModuleManager "
+ (turboModuleManager == null ? "not created" : "created"));
if (ReactFeatureFlags.enableTurboModuleDebugLogs) {
// TODO(T46487253): Remove after task is closed
FLog.e(
ReactConstants.TAG,
"ReactInstanceManager.createReactContext: TurboModuleManager "
+ (turboModuleManager == null ? "not created" : "created"));
}

catalystInstance.setTurboModuleManager(turboModuleManager);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,13 +583,15 @@ public NativeModule getNativeModule(String moduleName) {
if (getTurboModuleRegistry() != null) {
TurboModule turboModule = getTurboModuleRegistry().getModule(moduleName);

// TODO(T46487253): Remove after task is closed
FLog.e(
ReactConstants.TAG,
"CatalystInstanceImpl.getNativeModule: TurboModule "
+ moduleName
+ (turboModule == null ? " not" : "")
+ " found");
if (ReactFeatureFlags.enableTurboModuleDebugLogs) {
// TODO(T46487253): Remove after task is closed
FLog.e(
ReactConstants.TAG,
"CatalystInstanceImpl.getNativeModule: TurboModule "
+ moduleName
+ (turboModule == null ? " not" : "")
+ " found");
}
if (turboModule != null) {
return (NativeModule) turboModule;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class ReactFeatureFlags {
*/
public static volatile boolean useTurboModules = false;

/** Should we output debug logs to debug the TurboModule infra? */
public static volatile boolean enableTurboModuleDebugLogs = false;

/*
* This feature flag enables logs for Fabric
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.facebook.react.bridge.JavaScriptContextHolder;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
import com.facebook.react.turbomodule.core.interfaces.TurboModuleRegistry;
Expand Down Expand Up @@ -142,11 +143,14 @@ public TurboModule getModule(String moduleName) {
* Always return null after cleanup has started, so that getModule(moduleName) returns null.
*/

FLog.e(
ReactConstants.TAG,
"TurboModuleManager.getOrMaybeCreateTurboModuleHolder: Tried to require TurboModule "
+ moduleName
+ " after cleanup initiated");
if (ReactFeatureFlags.enableTurboModuleDebugLogs) {
// TODO(T46487253): Remove after task is closed
FLog.e(
ReactConstants.TAG,
"TurboModuleManager.getOrMaybeCreateTurboModuleHolder: Tried to require TurboModule "
+ moduleName
+ " after cleanup initiated");
}
return null;
}

Expand Down

0 comments on commit 97bc084

Please sign in to comment.