MCPcopy Index your code
hub / github.com/react/react / disableLogs

Function disableLogs

packages/shared/ConsolePatchingDev.js:27–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25disabledLog.__reactDisabledLog = true;
26
27export function disableLogs(): void {
28 if (__DEV__) {
29 if (disabledDepth === 0) {
30 /* eslint-disable react-internal/no-production-logging */
31 prevLog = console.log;
32 prevInfo = console.info;
33 prevWarn = console.warn;
34 prevError = console.error;
35 prevGroup = console.group;
36 prevGroupCollapsed = console.groupCollapsed;
37 prevGroupEnd = console.groupEnd;
38 // https://github.com/facebook/react/issues/19099
39 const props = {
40 configurable: true,
41 enumerable: true,
42 value: disabledLog,
43 writable: true,
44 };
45 // $FlowFixMe[cannot-write] Flow thinks console is immutable.
46 Object.defineProperties(console, {
47 info: props,
48 log: props,
49 warn: props,
50 error: props,
51 group: props,
52 groupCollapsed: props,
53 groupEnd: props,
54 });
55 }
56 disabledDepth++;
57 }
58}
59
60export function reenableLogs(): void {
61 if (__DEV__) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected