mirror of https://github.com/status-im/metro.git
Also call the original `console` methods if they exist
Summary: Ex. When `console.log` or similar is called, this will call the original method, which can be quite useful. For example, under iOS, this will log to the Safari console debugger, which has an expandable UI for inspecting objects, etc., and is also just useful if you are using that as a REPL. I don't believe this incurs a meaningful performance penalty unless the console is open, but it would be easy to stick behind a flag if that is a problem. Closes https://github.com/facebook/react-native/pull/2486 Reviewed By: @svcscm Differential Revision: D2472470 Pulled By: @vjeux
This commit is contained in:
parent
cea98fdef1
commit
c7ec04b253
|
@ -367,6 +367,9 @@
|
|||
};
|
||||
|
||||
function setupConsole(global) {
|
||||
|
||||
var originalConsole = global.console;
|
||||
|
||||
if (!global.nativeLoggingHook) {
|
||||
return;
|
||||
}
|
||||
|
@ -462,6 +465,16 @@
|
|||
table: consoleTablePolyfill
|
||||
};
|
||||
|
||||
// If available, also call the original `console` method since that is
|
||||
// sometimes useful. Ex: on OS X, this will let you see rich output in
|
||||
// the Safari Web Inspector console.
|
||||
Object.keys(global.console).forEach(methodName => {
|
||||
var reactNativeMethod = global.console[methodName];
|
||||
global.console[methodName] = function() {
|
||||
originalConsole[methodName](...arguments);
|
||||
reactNativeMethod.apply(global.console, arguments);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
|
|
Loading…
Reference in New Issue