Skip to content

Commit

Permalink
Fix expose originalConsole issue (#22844)
Browse files Browse the repository at this point in the history
Summary:
The "originalConsole" expose is incorrect in the "polyfills/console.js"

Changelog:
----------

[GENERAL] [Fixed] - Fixed originalConsole expose issue
Pull Request resolved: #22844

Differential Revision: D13579480

Pulled By: cpojer

fbshipit-source-id: 1d3ad84d3560b757df23170924af9c7655738871
  • Loading branch information
shenjunru authored and facebook-github-bot committed Jan 4, 2019
1 parent 2b883ab commit 7de2f77
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Libraries/polyfills/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,14 @@ function consoleGroupEndPolyfill() {

if (global.nativeLoggingHook) {
const originalConsole = global.console;
// Preserve the original `console` as `originalConsole`
if (__DEV__ && originalConsole) {
const descriptor = Object.getOwnPropertyDescriptor(global, 'console');
if (descriptor) {
Object.defineProperty(global, 'originalConsole', descriptor);
}
}

global.console = {
error: getNativeLogFunction(LOG_LEVELS.error),
info: getNativeLogFunction(LOG_LEVELS.info),
Expand All @@ -532,12 +540,6 @@ if (global.nativeLoggingHook) {
// sometimes useful. Ex: on OS X, this will let you see rich output in
// the Safari Web Inspector console.
if (__DEV__ && originalConsole) {
// Preserve the original `console` as `originalConsole`
const descriptor = Object.getOwnPropertyDescriptor(global, 'console');
if (descriptor) {
Object.defineProperty(global, 'originalConsole', descriptor);
}

Object.keys(console).forEach(methodName => {
const reactNativeMethod = console[methodName];
if (originalConsole[methodName]) {
Expand Down

0 comments on commit 7de2f77

Please sign in to comment.