Skip to content

Commit

Permalink
Remove Warning: prefix and toString on console Arguments (#29839)
Browse files Browse the repository at this point in the history
Basically make `console.error` and `console.warn` behave like normal -
when a component stack isn't appended. I need this because I need to be
able to print rich logs with the component stack option and to be able
to disable instrumentation completely in `console.createTask`
environments that don't need it.

Currently we can't print logs with richer objects because they're
toString:ed first. In practice, pretty much all arguments we log are
already toString:ed so it's not necessary anyway. Some might be like a
number. So it would only be a problem if some environment can't handle
proper consoles but then it's up to that environment to toString it
before logging.

The `Warning: ` prefix is historic and is both noisy and confusing. It's
mostly unnecessary since the UI surrounding `console.error` and
`console.warn` tend to have visual treatment around it anyway. However,
it's actively misleading when `console.error` gets prefixed with a
Warning that we consider an error level. There's an argument to be made
that some of our `console.error` don't make the bar for an error but
then the argument is to downgrade each of those to `console.warn` - not
to brand all our actual error logging with `Warning: `.

Apparently something needs to change in React Native before landing this
because it depends on the prefix somehow which probably doesn't make
sense already.

DiffTrain build for commit 2774208.
  • Loading branch information
sebmarkbage committed Jun 10, 2024
1 parent 72d1823 commit 810dff6
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 106 deletions.
2 changes: 1 addition & 1 deletion compiled-rn/VERSION_NATIVE_FB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.0.0-native-fb-bf1bb2e5e5-20240610
19.0.0-native-fb-2774208039-20240610
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<da42891998648234a32c9a1ac70d9bce>>
* @generated SignedSource<<e9c8f9f36a45a6dd3249367e7f40a6db>>
*/

"use strict";
Expand Down Expand Up @@ -152,18 +152,11 @@ __DEV__ &&
printWarning("error", format, args, Error("react-stack-top-frame"));
}
function printWarning(level, format, args, currentStack) {
var isErrorLogger =
"%s\n\n%s\n" === format || "%o\n\n%s\n\n%s\n" === format;
ReactSharedInternals.getCurrentStack &&
((currentStack = ReactSharedInternals.getCurrentStack(currentStack)),
"" !== currentStack &&
((format += "%s"), (args = args.concat([currentStack]))));
isErrorLogger
? args.unshift(format)
: ((args = args.map(function (item) {
return String(item);
})),
args.unshift("Warning: " + format));
args.unshift(format);
Function.prototype.apply.call(console[level], console, args);
}
function _defineProperties(target, props) {
Expand Down Expand Up @@ -15049,14 +15042,14 @@ __DEV__ &&
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
getCurrentFiber: getCurrentFiberForDevTools,
reconcilerVersion: "19.0.0-native-fb-bf1bb2e5e5-20240610"
reconcilerVersion: "19.0.0-native-fb-2774208039-20240610"
});
})({
findFiberByHostInstance: function () {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 1,
version: "19.0.0-native-fb-bf1bb2e5e5-20240610",
version: "19.0.0-native-fb-2774208039-20240610",
rendererPackageName: "react-test-renderer"
});
exports._Scheduler = Scheduler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9920f84659406d21dcf5429e76df93eb>>
* @generated SignedSource<<db4dd88f7d1228b66c0f9b5647536e42>>
*/

"use strict";
Expand Down Expand Up @@ -9336,7 +9336,7 @@ var devToolsConfig$jscomp$inline_1048 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-native-fb-bf1bb2e5e5-20240610",
version: "19.0.0-native-fb-2774208039-20240610",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1235 = {
Expand Down Expand Up @@ -9367,7 +9367,7 @@ var internals$jscomp$inline_1235 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-bf1bb2e5e5-20240610"
reconcilerVersion: "19.0.0-native-fb-2774208039-20240610"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1236 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<8346d33fcde7920e58c0769c267354c4>>
* @generated SignedSource<<ee84d20386606858c48dfc7bb7fcd98b>>
*/

"use strict";
Expand Down Expand Up @@ -9958,7 +9958,7 @@ var devToolsConfig$jscomp$inline_1131 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-native-fb-bf1bb2e5e5-20240610",
version: "19.0.0-native-fb-2774208039-20240610",
rendererPackageName: "react-test-renderer"
};
(function (internals) {
Expand Down Expand Up @@ -10002,7 +10002,7 @@ var devToolsConfig$jscomp$inline_1131 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-bf1bb2e5e5-20240610"
reconcilerVersion: "19.0.0-native-fb-2774208039-20240610"
});
exports._Scheduler = Scheduler;
exports.act = act;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9e2dad0789cdb57b65878831989d6b55>>
* @generated SignedSource<<a7dfd81316b971431720d69e9f261fbf>>
*/

"use strict";
Expand All @@ -22,22 +22,13 @@ __DEV__ &&
_key2++
)
args[_key2 - 1] = arguments[_key2];
printWarning("error", format, args, Error("react-stack-top-frame"));
}
function printWarning(level, format, args, currentStack) {
var isErrorLogger =
"%s\n\n%s\n" === format || "%o\n\n%s\n\n%s\n" === format;
_len2 = format;
_key2 = Error("react-stack-top-frame");
ReactSharedInternals.getCurrentStack &&
((currentStack = ReactSharedInternals.getCurrentStack(currentStack)),
"" !== currentStack &&
((format += "%s"), (args = args.concat([currentStack]))));
isErrorLogger
? args.unshift(format)
: ((args = args.map(function (item) {
return String(item);
})),
args.unshift("Warning: " + format));
Function.prototype.apply.call(console[level], console, args);
((_key2 = ReactSharedInternals.getCurrentStack(_key2)),
"" !== _key2 && ((_len2 += "%s"), (args = args.concat([_key2]))));
args.unshift(_len2);
Function.prototype.apply.call(console.error, console, args);
}
function getComponentNameFromType(type) {
if (null == type) return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<4d095073d7f6f1a36d5b981e9c2a52aa>>
* @generated SignedSource<<1e831dc318079da75149235e0e09d92d>>
*/

"use strict";
Expand All @@ -22,22 +22,13 @@ __DEV__ &&
_key2++
)
args[_key2 - 1] = arguments[_key2];
printWarning("error", format, args, Error("react-stack-top-frame"));
}
function printWarning(level, format, args, currentStack) {
var isErrorLogger =
"%s\n\n%s\n" === format || "%o\n\n%s\n\n%s\n" === format;
_len2 = format;
_key2 = Error("react-stack-top-frame");
ReactSharedInternals.getCurrentStack &&
((currentStack = ReactSharedInternals.getCurrentStack(currentStack)),
"" !== currentStack &&
((format += "%s"), (args = args.concat([currentStack]))));
isErrorLogger
? args.unshift(format)
: ((args = args.map(function (item) {
return String(item);
})),
args.unshift("Warning: " + format));
Function.prototype.apply.call(console[level], console, args);
((_key2 = ReactSharedInternals.getCurrentStack(_key2)),
"" !== _key2 && ((_len2 += "%s"), (args = args.concat([_key2]))));
args.unshift(_len2);
Function.prototype.apply.call(console.error, console, args);
}
function getComponentNameFromType(type) {
if (null == type) return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<c21f501f8b44219eb9f3f5d971634c05>>
* @generated SignedSource<<4e0e4b457140b7f25071b271f8f187d2>>
*/

"use strict";
Expand Down Expand Up @@ -55,18 +55,11 @@ __DEV__ &&
printWarning("error", format, args, Error("react-stack-top-frame"));
}
function printWarning(level, format, args, currentStack) {
var isErrorLogger =
"%s\n\n%s\n" === format || "%o\n\n%s\n\n%s\n" === format;
ReactSharedInternals.getCurrentStack &&
((currentStack = ReactSharedInternals.getCurrentStack(currentStack)),
"" !== currentStack &&
((format += "%s"), (args = args.concat([currentStack]))));
isErrorLogger
? args.unshift(format)
: ((args = args.map(function (item) {
return String(item);
})),
args.unshift("Warning: " + format));
args.unshift(format);
Function.prototype.apply.call(console[level], console, args);
}
function warnNoop(publicInstance, callerName) {
Expand Down Expand Up @@ -1748,7 +1741,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.0.0-native-fb-bf1bb2e5e5-20240610";
exports.version = "19.0.0-native-fb-2774208039-20240610";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2c83bccf84bb8a9740b77d55bf1f96ca>>
* @generated SignedSource<<138668c29d55fc3ae4dbdcec9581ff7b>>
*/

"use strict";
Expand Down Expand Up @@ -604,4 +604,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-native-fb-bf1bb2e5e5-20240610";
exports.version = "19.0.0-native-fb-2774208039-20240610";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2d729030ac0bf8fa0eb464bb2f16e724>>
* @generated SignedSource<<540135ee9c1a9fde97799dda98a4b743>>
*/

"use strict";
Expand Down Expand Up @@ -608,7 +608,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-native-fb-bf1bb2e5e5-20240610";
exports.version = "19.0.0-native-fb-2774208039-20240610";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bf1bb2e5e52733a9577848f2913d06edcf24df14
277420803947724b43c47bbc47d3a353553868f1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<50de4ae8b3ee39790e8c9b7e11f89ad9>>
* @generated SignedSource<<b5fd1f738b9e23ac9f724f39960a3e88>>
*/

"use strict";
Expand Down Expand Up @@ -156,18 +156,11 @@ __DEV__ &&
}
}
function printWarning(level, format, args, currentStack) {
var isErrorLogger =
"%s\n\n%s\n" === format || "%o\n\n%s\n\n%s\n" === format;
ReactSharedInternals.getCurrentStack &&
((currentStack = ReactSharedInternals.getCurrentStack(currentStack)),
"" !== currentStack &&
((format += "%s"), (args = args.concat([currentStack]))));
isErrorLogger
? args.unshift(format)
: ((args = args.map(function (item) {
return String(item);
})),
args.unshift("Warning: " + format));
args.unshift(format);
Function.prototype.apply.call(console[level], console, args);
}
function validateEventDispatches(event) {
Expand Down Expand Up @@ -16681,12 +16674,12 @@ __DEV__ &&
scheduleRoot: scheduleRoot,
setRefreshHandler: setRefreshHandler,
getCurrentFiber: getCurrentFiberForDevTools,
reconcilerVersion: "19.0.0-native-fb-bf1bb2e5e5-20240610"
reconcilerVersion: "19.0.0-native-fb-2774208039-20240610"
});
})({
findFiberByHostInstance: getInstanceFromNode,
bundleType: 1,
version: "19.0.0-native-fb-bf1bb2e5e5-20240610",
version: "19.0.0-native-fb-2774208039-20240610",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<1dd48ba25960696fbbef43b558b17207>>
* @generated SignedSource<<1619271d414b4256cd58ad54d07e0b4a>>
*/

"use strict";
Expand Down Expand Up @@ -10591,7 +10591,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1125 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-native-fb-bf1bb2e5e5-20240610",
version: "19.0.0-native-fb-2774208039-20240610",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -10634,7 +10634,7 @@ var internals$jscomp$inline_1351 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-bf1bb2e5e5-20240610"
reconcilerVersion: "19.0.0-native-fb-2774208039-20240610"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1352 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<db1518fef4ce31ff3695820ce5911be7>>
* @generated SignedSource<<df6f3910cc77174c9921429231bb3527>>
*/

"use strict";
Expand Down Expand Up @@ -11297,7 +11297,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1206 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-native-fb-bf1bb2e5e5-20240610",
version: "19.0.0-native-fb-2774208039-20240610",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -11353,7 +11353,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-native-fb-bf1bb2e5e5-20240610"
reconcilerVersion: "19.0.0-native-fb-2774208039-20240610"
});
exports.createPortal = function (children, containerTag) {
return createPortal$1(
Expand Down
Loading

0 comments on commit 810dff6

Please sign in to comment.