mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove infoLog invocations from react-native and rn-tester (#51600)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51600 The `infoLog` is a `console.log` wrapper to separate ad-hoc console debug logging, however console logs are already used in some files in rn-tester (ex. RNTesterAppShared.js). The same applies to files in react-native package. Changelog: [General][Changed] - Removed `infoLog` from react-native package Reviewed By: huntie Differential Revision: D75402930 fbshipit-source-id: 1a14a9122552130415f058d3647d715225321ab8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
827a6851d0
commit
8a0cfec815
@@ -15,7 +15,6 @@ import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNa
|
||||
import EventEmitter from '../vendor/emitter/EventEmitter';
|
||||
|
||||
const BatchedBridge = require('../BatchedBridge/BatchedBridge').default;
|
||||
const infoLog = require('../Utilities/infoLog').default;
|
||||
const TaskQueue = require('./TaskQueue').default;
|
||||
const invariant = require('invariant');
|
||||
|
||||
@@ -74,7 +73,7 @@ const InteractionManagerImpl = {
|
||||
* Notify manager that an interaction has started.
|
||||
*/
|
||||
createInteractionHandle(): Handle {
|
||||
DEBUG && infoLog('InteractionManager: create interaction handle');
|
||||
DEBUG && console.log('InteractionManager: create interaction handle');
|
||||
_scheduleUpdate();
|
||||
const handle = ++_inc;
|
||||
_addInteractionSet.add(handle);
|
||||
@@ -85,7 +84,7 @@ const InteractionManagerImpl = {
|
||||
* Notify manager that an interaction has completed.
|
||||
*/
|
||||
clearInteractionHandle(handle: Handle) {
|
||||
DEBUG && infoLog('InteractionManager: clear interaction handle');
|
||||
DEBUG && console.log('InteractionManager: clear interaction handle');
|
||||
invariant(!!handle, 'InteractionManager: Must provide a handle to clear.');
|
||||
_scheduleUpdate();
|
||||
_addInteractionSet.delete(handle);
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const infoLog = require('../Utilities/infoLog').default;
|
||||
|
||||
type Handler = {
|
||||
onIterate?: () => void,
|
||||
onStall: (params: {lastInterval: number, busyTime: number, ...}) => ?string,
|
||||
@@ -35,7 +33,7 @@ const JSEventLoopWatchdog = {
|
||||
return {stallCount, totalStallTime, longestStall, acceptableBusyTime};
|
||||
},
|
||||
reset: function () {
|
||||
infoLog('JSEventLoopWatchdog: reset');
|
||||
console.log('JSEventLoopWatchdog: reset');
|
||||
totalStallTime = 0;
|
||||
stallCount = 0;
|
||||
longestStall = 0;
|
||||
@@ -65,7 +63,7 @@ const JSEventLoopWatchdog = {
|
||||
handlers.forEach(handler => {
|
||||
msg += handler.onStall({lastInterval, busyTime}) || '';
|
||||
});
|
||||
infoLog(msg);
|
||||
console.log(msg);
|
||||
}
|
||||
handlers.forEach(handler => {
|
||||
handler.onIterate && handler.onIterate();
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const infoLog = require('../Utilities/infoLog').default;
|
||||
const invariant = require('invariant');
|
||||
|
||||
export type SimpleTask = {
|
||||
@@ -100,10 +99,10 @@ class TaskQueue {
|
||||
const task = queue.shift();
|
||||
try {
|
||||
if (typeof task === 'object' && task.gen) {
|
||||
DEBUG && infoLog('TaskQueue: genPromise for task ' + task.name);
|
||||
DEBUG && console.log('TaskQueue: genPromise for task ' + task.name);
|
||||
this._genPromise(task);
|
||||
} else if (typeof task === 'object' && task.run) {
|
||||
DEBUG && infoLog('TaskQueue: run task ' + task.name);
|
||||
DEBUG && console.log('TaskQueue: run task ' + task.name);
|
||||
task.run();
|
||||
} else {
|
||||
invariant(
|
||||
@@ -111,7 +110,7 @@ class TaskQueue {
|
||||
'Expected Function, SimpleTask, or PromiseTask, but got:\n' +
|
||||
JSON.stringify(task, null, 2),
|
||||
);
|
||||
DEBUG && infoLog('TaskQueue: run anonymous task');
|
||||
DEBUG && console.log('TaskQueue: run anonymous task');
|
||||
task();
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -141,7 +140,7 @@ class TaskQueue {
|
||||
) {
|
||||
this._queueStack.pop();
|
||||
DEBUG &&
|
||||
infoLog('TaskQueue: popped queue: ', {
|
||||
console.log('TaskQueue: popped queue: ', {
|
||||
stackIdx,
|
||||
queueStackSize: this._queueStack.length,
|
||||
});
|
||||
@@ -159,13 +158,13 @@ class TaskQueue {
|
||||
this._queueStack.push({tasks: [], popable: false});
|
||||
const stackIdx = this._queueStack.length - 1;
|
||||
const stackItem = this._queueStack[stackIdx];
|
||||
DEBUG && infoLog('TaskQueue: push new queue: ', {stackIdx});
|
||||
DEBUG && infoLog('TaskQueue: exec gen task ' + task.name);
|
||||
DEBUG && console.log('TaskQueue: push new queue: ', {stackIdx});
|
||||
DEBUG && console.log('TaskQueue: exec gen task ' + task.name);
|
||||
task
|
||||
.gen()
|
||||
.then(() => {
|
||||
DEBUG &&
|
||||
infoLog('TaskQueue: onThen for gen task ' + task.name, {
|
||||
console.log('TaskQueue: onThen for gen task ' + task.name, {
|
||||
stackIdx,
|
||||
queueStackSize: this._queueStack.length,
|
||||
});
|
||||
|
||||
@@ -24,7 +24,6 @@ import type {
|
||||
|
||||
import BugReporting from '../BugReporting/BugReporting';
|
||||
import createPerformanceLogger from '../Utilities/createPerformanceLogger';
|
||||
import infoLog from '../Utilities/infoLog';
|
||||
import SceneTracker from '../Utilities/SceneTracker';
|
||||
import {coerceDisplayMode} from './DisplayMode';
|
||||
import HeadlessJsTaskError from './HeadlessJsTaskError';
|
||||
@@ -167,7 +166,7 @@ export function runApplication(
|
||||
if (appKey !== 'LogBox') {
|
||||
const logParams = __DEV__ ? ` with ${JSON.stringify(appParameters)}` : '';
|
||||
const msg = `Running "${appKey}"${logParams}`;
|
||||
infoLog(msg);
|
||||
console.log(msg);
|
||||
BugReporting.addSource(
|
||||
'AppRegistry.runApplication' + runCount++,
|
||||
() => msg,
|
||||
@@ -199,7 +198,7 @@ export function setSurfaceProps(
|
||||
appKey +
|
||||
'" with ' +
|
||||
JSON.stringify(appParameters);
|
||||
infoLog(msg);
|
||||
console.log(msg);
|
||||
BugReporting.addSource(
|
||||
'AppRegistry.setSurfaceProps' + runCount++,
|
||||
() => msg,
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('infoLog', () => {
|
||||
const infoLog = require('../infoLog').default;
|
||||
|
||||
it('logs messages to the console', () => {
|
||||
console.log = jest.fn();
|
||||
|
||||
infoLog('This is a log message');
|
||||
|
||||
expect(console.log).toHaveBeenCalledWith('This is a log message');
|
||||
});
|
||||
|
||||
it('logs messages with multiple arguments to the console', () => {
|
||||
console.log = jest.fn();
|
||||
|
||||
const data = 'log';
|
||||
infoLog('This is a', data, 'message');
|
||||
|
||||
expect(console.log).toHaveBeenCalledWith('This is a', 'log', 'message');
|
||||
});
|
||||
});
|
||||
@@ -15,8 +15,6 @@ import type {
|
||||
Timespan,
|
||||
} from './IPerformanceLogger';
|
||||
|
||||
import infoLog from './infoLog';
|
||||
|
||||
const PRINT_TO_CONSOLE: false = false; // Type as false to prevent accidentally committing `true`;
|
||||
|
||||
export const getCurrentTimestamp: () => number =
|
||||
@@ -38,13 +36,16 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
) {
|
||||
if (this._closed) {
|
||||
if (PRINT_TO_CONSOLE && __DEV__) {
|
||||
infoLog('PerformanceLogger: addTimespan - has closed ignoring: ', key);
|
||||
console.log(
|
||||
'PerformanceLogger: addTimespan - has closed ignoring: ',
|
||||
key,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this._timespans[key]) {
|
||||
if (PRINT_TO_CONSOLE && __DEV__) {
|
||||
infoLog(
|
||||
console.log(
|
||||
'PerformanceLogger: Attempting to add a timespan that already exists ',
|
||||
key,
|
||||
);
|
||||
@@ -79,7 +80,7 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
this._extras = {};
|
||||
this._points = {};
|
||||
if (PRINT_TO_CONSOLE) {
|
||||
infoLog('PerformanceLogger.js', 'clear');
|
||||
console.log('PerformanceLogger.js', 'clear');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
this._extras = {};
|
||||
this._points = {};
|
||||
if (PRINT_TO_CONSOLE) {
|
||||
infoLog('PerformanceLogger.js', 'clearCompleted');
|
||||
console.log('PerformanceLogger.js', 'clearCompleted');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,17 +134,17 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
// log timespans
|
||||
for (const key in this._timespans) {
|
||||
if (this._timespans[key]?.totalTime != null) {
|
||||
infoLog(key + ': ' + this._timespans[key].totalTime + 'ms');
|
||||
console.log(key + ': ' + this._timespans[key].totalTime + 'ms');
|
||||
}
|
||||
}
|
||||
|
||||
// log extras
|
||||
infoLog(this._extras);
|
||||
console.log(this._extras);
|
||||
|
||||
// log points
|
||||
for (const key in this._points) {
|
||||
if (this._points[key] != null) {
|
||||
infoLog(key + ': ' + this._points[key] + 'ms');
|
||||
console.log(key + ': ' + this._points[key] + 'ms');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,13 +157,16 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
) {
|
||||
if (this._closed) {
|
||||
if (PRINT_TO_CONSOLE && __DEV__) {
|
||||
infoLog('PerformanceLogger: markPoint - has closed ignoring: ', key);
|
||||
console.log(
|
||||
'PerformanceLogger: markPoint - has closed ignoring: ',
|
||||
key,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this._points[key] != null) {
|
||||
if (PRINT_TO_CONSOLE && __DEV__) {
|
||||
infoLog(
|
||||
console.log(
|
||||
'PerformanceLogger: Attempting to mark a point that has been already logged ',
|
||||
key,
|
||||
);
|
||||
@@ -184,14 +188,14 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
setExtra(key: string, value: ExtraValue) {
|
||||
if (this._closed) {
|
||||
if (PRINT_TO_CONSOLE && __DEV__) {
|
||||
infoLog('PerformanceLogger: setExtra - has closed ignoring: ', key);
|
||||
console.log('PerformanceLogger: setExtra - has closed ignoring: ', key);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._extras.hasOwnProperty(key)) {
|
||||
if (PRINT_TO_CONSOLE && __DEV__) {
|
||||
infoLog(
|
||||
console.log(
|
||||
'PerformanceLogger: Attempting to set an extra that already exists ',
|
||||
{key, currentValue: this._extras[key], attemptedValue: value},
|
||||
);
|
||||
@@ -208,7 +212,7 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
) {
|
||||
if (this._closed) {
|
||||
if (PRINT_TO_CONSOLE && __DEV__) {
|
||||
infoLog(
|
||||
console.log(
|
||||
'PerformanceLogger: startTimespan - has closed ignoring: ',
|
||||
key,
|
||||
);
|
||||
@@ -218,7 +222,7 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
|
||||
if (this._timespans[key]) {
|
||||
if (PRINT_TO_CONSOLE && __DEV__) {
|
||||
infoLog(
|
||||
console.log(
|
||||
'PerformanceLogger: Attempting to start a timespan that already exists ',
|
||||
key,
|
||||
);
|
||||
@@ -231,7 +235,7 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
startExtras: extras,
|
||||
};
|
||||
if (PRINT_TO_CONSOLE) {
|
||||
infoLog('PerformanceLogger.js', 'start: ' + key);
|
||||
console.log('PerformanceLogger.js', 'start: ' + key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +246,10 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
) {
|
||||
if (this._closed) {
|
||||
if (PRINT_TO_CONSOLE && __DEV__) {
|
||||
infoLog('PerformanceLogger: stopTimespan - has closed ignoring: ', key);
|
||||
console.log(
|
||||
'PerformanceLogger: stopTimespan - has closed ignoring: ',
|
||||
key,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -250,7 +257,7 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
const timespan = this._timespans[key];
|
||||
if (!timespan || timespan.startTime == null) {
|
||||
if (PRINT_TO_CONSOLE && __DEV__) {
|
||||
infoLog(
|
||||
console.log(
|
||||
'PerformanceLogger: Attempting to end a timespan that has not started ',
|
||||
key,
|
||||
);
|
||||
@@ -259,7 +266,7 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
}
|
||||
if (timespan.endTime != null) {
|
||||
if (PRINT_TO_CONSOLE && __DEV__) {
|
||||
infoLog(
|
||||
console.log(
|
||||
'PerformanceLogger: Attempting to end a timespan that has already ended ',
|
||||
key,
|
||||
);
|
||||
@@ -271,7 +278,7 @@ class PerformanceLogger implements IPerformanceLogger {
|
||||
timespan.endTime = timestamp;
|
||||
timespan.totalTime = timespan.endTime - (timespan.startTime || 0);
|
||||
if (PRINT_TO_CONSOLE) {
|
||||
infoLog('PerformanceLogger.js', 'end: ' + key);
|
||||
console.log('PerformanceLogger.js', 'end: ' + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Intentional info-level logging for clear separation from ad-hoc console debug logging.
|
||||
*/
|
||||
function infoLog(...args: Array<mixed>): void {
|
||||
return console.log(...args);
|
||||
}
|
||||
|
||||
export default infoLog;
|
||||
@@ -8766,12 +8766,6 @@ declare export default typeof dismissKeyboard;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`public API should not change unintentionally Libraries/Utilities/infoLog.js 1`] = `
|
||||
"declare function infoLog(...args: Array<mixed>): void;
|
||||
declare export default typeof infoLog;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`public API should not change unintentionally Libraries/Utilities/logError.js 1`] = `
|
||||
"declare const logError: (...args: $ReadOnlyArray<mixed>) => void;
|
||||
declare export default typeof logError;
|
||||
|
||||
@@ -41,7 +41,6 @@ import {
|
||||
TextInput,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import infoLog from 'react-native/Libraries/Utilities/infoLog';
|
||||
|
||||
const PAGE_SIZE = 100;
|
||||
const NUM_PAGES = 10;
|
||||
@@ -402,7 +401,7 @@ class FlatListExample extends React.PureComponent<Props, State> {
|
||||
}) => {
|
||||
// Impressions can be logged here
|
||||
if (this.state.logViewable) {
|
||||
infoLog(
|
||||
console.log(
|
||||
'onViewableItemsChanged: ',
|
||||
info.changed.map(v => ({...v, item: '...'})),
|
||||
);
|
||||
|
||||
@@ -30,7 +30,6 @@ import RNTesterText from '../../components/RNTesterText';
|
||||
import * as React from 'react';
|
||||
import {useState} from 'react';
|
||||
import {Alert, FlatList, StyleSheet, View} from 'react-native';
|
||||
import infoLog from 'react-native/Libraries/Utilities/infoLog';
|
||||
|
||||
function MultiColumnExample(): React.Node {
|
||||
const [data, setData] = useState(genNewerItems(1000));
|
||||
@@ -96,7 +95,7 @@ function MultiColumnExample(): React.Node {
|
||||
}) => {
|
||||
// Impressions can be logged here
|
||||
if (logViewable) {
|
||||
infoLog(
|
||||
console.log(
|
||||
'onViewableItemsChanged: ',
|
||||
info.changed.map(v => ({...v, item: '...'})),
|
||||
);
|
||||
|
||||
@@ -38,7 +38,6 @@ import {
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import infoLog from 'react-native/Libraries/Utilities/infoLog';
|
||||
|
||||
const VIEWABILITY_CONFIG = {
|
||||
minimumViewTime: 3000,
|
||||
@@ -234,7 +233,7 @@ export function SectionList_scrollable(Props: {...}): React.MixedElement {
|
||||
}) => {
|
||||
// Impressions can be logged here
|
||||
if (logViewable) {
|
||||
infoLog(
|
||||
console.log(
|
||||
'onViewableItemsChanged: ',
|
||||
info.changed.map((v: Object) => ({
|
||||
...v,
|
||||
|
||||
Reference in New Issue
Block a user