Skip to content

Commit fa2842d

Browse files
rickhanloniifacebook-github-bot
authored andcommitted
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
1 parent 3982a2c commit fa2842d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Libraries/LogBox/LogBox.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,16 @@ if (__DEV__) {
143143
if (LogBoxData.isLogBoxErrorMessage(String(args[0]))) {
144144
originalConsoleError(...args);
145145
return;
146+
} else {
147+
// Be sure to pass LogBox warnings through.
148+
originalConsoleWarn(...args);
146149
}
147150

148151
try {
149152
if (!isRCTLogAdviceWarning(...args)) {
150153
const {category, message, componentStack} = parseLogBoxLog(args);
151154

152155
if (!LogBoxData.isMessageIgnored(message.content)) {
153-
// Be sure to pass LogBox warnings through.
154-
originalConsoleWarn(...args);
155-
156156
LogBoxData.addLog({
157157
level: 'warn',
158158
category,
@@ -205,12 +205,12 @@ if (__DEV__) {
205205
args[0] = `Warning: ${filterResult.finalFormat}`;
206206
const {category, message, componentStack} = parseLogBoxLog(args);
207207

208-
if (!LogBoxData.isMessageIgnored(message.content)) {
209-
// Interpolate the message so they are formatted for adb and other CLIs.
210-
// This is different than the message.content above because it includes component stacks.
211-
const interpolated = parseInterpolation(args);
212-
originalConsoleError(interpolated.message.content);
208+
// Interpolate the message so they are formatted for adb and other CLIs.
209+
// This is different than the message.content above because it includes component stacks.
210+
const interpolated = parseInterpolation(args);
211+
originalConsoleError(interpolated.message.content);
213212

213+
if (!LogBoxData.isMessageIgnored(message.content)) {
214214
LogBoxData.addLog({
215215
level,
216216
category,

0 commit comments

Comments
 (0)