mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Do not send log messages to Metro when Platform.isTesting is set
Summary: Ideally this should fix `//Libraries/FBReactKit:HiPriServerSnapshotTestsFacebookRedbox`. Reviewed By: PeteTheHeat Differential Revision: D15578792 fbshipit-source-id: 83dd227122170721c0f33c54e0f0e23e810569ae
This commit is contained in:
committed by
Facebook Github Bot
parent
3b65d2c2c8
commit
dc0106e4f4
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
import Platform from '../Utilities/Platform';
|
||||
|
||||
/**
|
||||
* Sets up developer tools for React Native.
|
||||
* You can use this module directly, or just require InitializeCore.
|
||||
@@ -26,13 +28,15 @@ if (__DEV__) {
|
||||
JSInspector.registerAgent(require('../JSInspector/NetworkAgent'));
|
||||
}
|
||||
|
||||
const logToConsole = require('./Devtools/logToConsole');
|
||||
['log', 'warn', 'info', 'trace'].forEach(level => {
|
||||
const originalFunction = console[level];
|
||||
// $FlowFixMe Overwrite console methods
|
||||
console[level] = function(...args) {
|
||||
logToConsole(level, args);
|
||||
originalFunction.apply(console, args);
|
||||
};
|
||||
});
|
||||
if (!Platform.isTesting) {
|
||||
const logToConsole = require('./Devtools/logToConsole');
|
||||
['log', 'warn', 'info', 'trace'].forEach(level => {
|
||||
const originalFunction = console[level];
|
||||
// $FlowFixMe Overwrite console methods
|
||||
console[level] = function(...args) {
|
||||
logToConsole(level, args);
|
||||
originalFunction.apply(console, args);
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user