Remove Warning: prefix and toString on console Arguments (#29839)

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 https://github.com/facebook/react/commit/277420803947724b43c47bbc47d3a353553868f1.
This commit is contained in:
sebmarkbage
2024-06-10 22:46:48 +00:00
parent 72d182398e
commit 810dff656e
16 changed files with 60 additions and 106 deletions
+1 -1
View File
@@ -1 +1 @@
19.0.0-native-fb-bf1bb2e5e5-20240610
19.0.0-native-fb-2774208039-20240610
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<da42891998648234a32c9a1ac70d9bce>>
* @generated SignedSource<<e9c8f9f36a45a6dd3249367e7f40a6db>>
*/
"use strict";
@@ -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) {
@@ -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;
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9920f84659406d21dcf5429e76df93eb>>
* @generated SignedSource<<db4dd88f7d1228b66c0f9b5647536e42>>
*/
"use strict";
@@ -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 = {
@@ -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__;
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<8346d33fcde7920e58c0769c267354c4>>
* @generated SignedSource<<ee84d20386606858c48dfc7bb7fcd98b>>
*/
"use strict";
@@ -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) {
@@ -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;
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9e2dad0789cdb57b65878831989d6b55>>
* @generated SignedSource<<a7dfd81316b971431720d69e9f261fbf>>
*/
"use strict";
@@ -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;
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<4d095073d7f6f1a36d5b981e9c2a52aa>>
* @generated SignedSource<<1e831dc318079da75149235e0e09d92d>>
*/
"use strict";
@@ -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;
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<c21f501f8b44219eb9f3f5d971634c05>>
* @generated SignedSource<<4e0e4b457140b7f25071b271f8f187d2>>
*/
"use strict";
@@ -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) {
@@ -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 &&
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2c83bccf84bb8a9740b77d55bf1f96ca>>
* @generated SignedSource<<138668c29d55fc3ae4dbdcec9581ff7b>>
*/
"use strict";
@@ -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";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2d729030ac0bf8fa0eb464bb2f16e724>>
* @generated SignedSource<<540135ee9c1a9fde97799dda98a4b743>>
*/
"use strict";
@@ -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 &&
@@ -1 +1 @@
bf1bb2e5e52733a9577848f2913d06edcf24df14
277420803947724b43c47bbc47d3a353553868f1
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<50de4ae8b3ee39790e8c9b7e11f89ad9>>
* @generated SignedSource<<b5fd1f738b9e23ac9f724f39960a3e88>>
*/
"use strict";
@@ -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) {
@@ -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,
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<1dd48ba25960696fbbef43b558b17207>>
* @generated SignedSource<<1619271d414b4256cd58ad54d07e0b4a>>
*/
"use strict";
@@ -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,
@@ -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__;
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<db1518fef4ce31ff3695820ce5911be7>>
* @generated SignedSource<<df6f3910cc77174c9921429231bb3527>>
*/
"use strict";
@@ -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,
@@ -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(
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<7faf4baf7672a196e4363c40fd86f64a>>
* @generated SignedSource<<3f15f53fe07104640c18ca42c6b3b13a>>
*/
"use strict";
@@ -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) {
@@ -15060,7 +15053,7 @@ __DEV__ &&
(relativeNode = relativeToNativeNode._nativeTag);
null == relativeNode
? error$jscomp$0(
"Warning: ref.measureLayout must be called with a node handle or a ref to a native component."
"ref.measureLayout must be called with a node handle or a ref to a native component."
)
: ReactNativePrivateInterface.UIManager.measureLayout(
this._nativeTag,
@@ -16870,11 +16863,11 @@ __DEV__ &&
var emptyObject = {};
Object.freeze(emptyObject);
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-native-fb-bf1bb2e5e5-20240610" !== isomorphicReactPackageVersion)
if ("19.0.0-native-fb-2774208039-20240610" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.0.0-native-fb-bf1bb2e5e5-20240610\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.0.0-native-fb-2774208039-20240610\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
@@ -16922,12 +16915,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: getInstanceFromTag,
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,
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<ea2e460a3ad6abb48b0483a875eb877e>>
* @generated SignedSource<<aa56dfafc02539ff90e5976580e28082>>
*/
"use strict";
@@ -10734,11 +10734,11 @@ function traverseOwnerTreeUp(hierarchy, instance) {
traverseOwnerTreeUp(hierarchy, instance);
}
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-native-fb-bf1bb2e5e5-20240610" !== isomorphicReactPackageVersion)
if ("19.0.0-native-fb-2774208039-20240610" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.0.0-native-fb-bf1bb2e5e5-20240610\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.0.0-native-fb-2774208039-20240610\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
@@ -10788,7 +10788,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1193 = {
findFiberByHostInstance: getInstanceFromTag,
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,
@@ -10831,7 +10831,7 @@ var internals$jscomp$inline_1440 = {
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_1441 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<def6ce7d1f10a322d57804f56a40ec7e>>
* @generated SignedSource<<26bd930784bf9d12f1a5933e0204451c>>
*/
"use strict";
@@ -11441,11 +11441,11 @@ function traverseOwnerTreeUp(hierarchy, instance) {
traverseOwnerTreeUp(hierarchy, instance);
}
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-native-fb-bf1bb2e5e5-20240610" !== isomorphicReactPackageVersion)
if ("19.0.0-native-fb-2774208039-20240610" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.0.0-native-fb-bf1bb2e5e5-20240610\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.0.0-native-fb-2774208039-20240610\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
@@ -11495,7 +11495,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1274 = {
findFiberByHostInstance: getInstanceFromTag,
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,
@@ -11551,7 +11551,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.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
computeComponentStackForErrorReporting: function (reactTag) {