From fa2842d113f04c8d33d2f71f43d4232e470b77ac Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Wed, 26 Oct 2022 22:03:19 -0700 Subject: [PATCH] Do not filter errors/warnings from console Summary: ## Overview When I implemented `ignoreLogs` it was originally just to move `console.ignoreYellowBox` over to LogBox. When I did that, I also added filtering for console messages too. My thought process was: Developers probably don't want to configure hiding logs twice, so the LogBox method can handle both. This was a mistake. We should never hide console errors and warnings, because it completely silences important feedback to the users such as deprecation warnings. These issues should be fixed, not silenced, and since adding the silencing behavior it's clear that this feature is being abused to ignore legitimate warnings that need address. Issue #33557 is a great reason why - the correct fix for this is not to ignore the errors, it's to address the deprecation / removal of the API. Allowing an easy `ignoreLog` method to hide the problem made this migration much more painful. Thus, we're reverting back to the pre-logbox behavior of always showing console logs, even if they're ignored by LogBox in the app UI. Hopefully, this results in more of these issue being addressed instead of ignored. Changelog: [General] [Changed] - Do not filter errors/warnings from console Reviewed By: yungsters Differential Revision: D40724661 fbshipit-source-id: de3d2db1b0c32dee96acf92c9b1ca07ba0f4e218 --- Libraries/LogBox/LogBox.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Libraries/LogBox/LogBox.js b/Libraries/LogBox/LogBox.js index 35cd3e32ea2447..a597ca5acf9199 100644 --- a/Libraries/LogBox/LogBox.js +++ b/Libraries/LogBox/LogBox.js @@ -143,6 +143,9 @@ if (__DEV__) { if (LogBoxData.isLogBoxErrorMessage(String(args[0]))) { originalConsoleError(...args); return; + } else { + // Be sure to pass LogBox warnings through. + originalConsoleWarn(...args); } try { @@ -150,9 +153,6 @@ if (__DEV__) { const {category, message, componentStack} = parseLogBoxLog(args); if (!LogBoxData.isMessageIgnored(message.content)) { - // Be sure to pass LogBox warnings through. - originalConsoleWarn(...args); - LogBoxData.addLog({ level: 'warn', category, @@ -205,12 +205,12 @@ if (__DEV__) { args[0] = `Warning: ${filterResult.finalFormat}`; const {category, message, componentStack} = parseLogBoxLog(args); - if (!LogBoxData.isMessageIgnored(message.content)) { - // Interpolate the message so they are formatted for adb and other CLIs. - // This is different than the message.content above because it includes component stacks. - const interpolated = parseInterpolation(args); - originalConsoleError(interpolated.message.content); + // Interpolate the message so they are formatted for adb and other CLIs. + // This is different than the message.content above because it includes component stacks. + const interpolated = parseInterpolation(args); + originalConsoleError(interpolated.message.content); + if (!LogBoxData.isMessageIgnored(message.content)) { LogBoxData.addLog({ level, category,