Skip to content

Commit

Permalink
Do not filter errors/warnings from console
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Oct 27, 2022
1 parent 3982a2c commit fa2842d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Libraries/LogBox/LogBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,16 @@ if (__DEV__) {
if (LogBoxData.isLogBoxErrorMessage(String(args[0]))) {
originalConsoleError(...args);
return;
} else {
// Be sure to pass LogBox warnings through.
originalConsoleWarn(...args);
}

try {
if (!isRCTLogAdviceWarning(...args)) {
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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit fa2842d

Please sign in to comment.