diff --git a/packages/react-native/Libraries/Interaction/InteractionManager.js b/packages/react-native/Libraries/Interaction/InteractionManager.js index 4fc23e9066c1..966195602c32 100644 --- a/packages/react-native/Libraries/Interaction/InteractionManager.js +++ b/packages/react-native/Libraries/Interaction/InteractionManager.js @@ -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); diff --git a/packages/react-native/Libraries/Interaction/JSEventLoopWatchdog.js b/packages/react-native/Libraries/Interaction/JSEventLoopWatchdog.js index ab25a1c89051..898a246d666b 100644 --- a/packages/react-native/Libraries/Interaction/JSEventLoopWatchdog.js +++ b/packages/react-native/Libraries/Interaction/JSEventLoopWatchdog.js @@ -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(); diff --git a/packages/react-native/Libraries/Interaction/TaskQueue.js b/packages/react-native/Libraries/Interaction/TaskQueue.js index e3781530bf8f..720a286c0890 100644 --- a/packages/react-native/Libraries/Interaction/TaskQueue.js +++ b/packages/react-native/Libraries/Interaction/TaskQueue.js @@ -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, }); diff --git a/packages/react-native/Libraries/ReactNative/AppRegistryImpl.js b/packages/react-native/Libraries/ReactNative/AppRegistryImpl.js index 2dfb05ddd7bf..c6ca7591f072 100644 --- a/packages/react-native/Libraries/ReactNative/AppRegistryImpl.js +++ b/packages/react-native/Libraries/ReactNative/AppRegistryImpl.js @@ -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, diff --git a/packages/react-native/Libraries/Utilities/__tests__/infoLog-test.js b/packages/react-native/Libraries/Utilities/__tests__/infoLog-test.js deleted file mode 100644 index 45a0739330cb..000000000000 --- a/packages/react-native/Libraries/Utilities/__tests__/infoLog-test.js +++ /dev/null @@ -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'); - }); -}); diff --git a/packages/react-native/Libraries/Utilities/createPerformanceLogger.js b/packages/react-native/Libraries/Utilities/createPerformanceLogger.js index fba6d7711aef..8db0c9df19b1 100644 --- a/packages/react-native/Libraries/Utilities/createPerformanceLogger.js +++ b/packages/react-native/Libraries/Utilities/createPerformanceLogger.js @@ -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); } } } diff --git a/packages/react-native/Libraries/Utilities/infoLog.js b/packages/react-native/Libraries/Utilities/infoLog.js deleted file mode 100644 index 963e1356c75a..000000000000 --- a/packages/react-native/Libraries/Utilities/infoLog.js +++ /dev/null @@ -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): void { - return console.log(...args); -} - -export default infoLog; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 4b67135a1de0..bbb3ca116e72 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -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): void; -declare export default typeof infoLog; -" -`; - exports[`public API should not change unintentionally Libraries/Utilities/logError.js 1`] = ` "declare const logError: (...args: $ReadOnlyArray) => void; declare export default typeof logError; diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js index 09d35604f84b..f4354540e368 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js @@ -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 { }) => { // Impressions can be logged here if (this.state.logViewable) { - infoLog( + console.log( 'onViewableItemsChanged: ', info.changed.map(v => ({...v, item: '...'})), ); diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-multiColumn.js b/packages/rn-tester/js/examples/FlatList/FlatList-multiColumn.js index e47928ad8762..1c0bcdb89df8 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-multiColumn.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-multiColumn.js @@ -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: '...'})), ); diff --git a/packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js b/packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js index 73d630dc235c..019afd0cfcd6 100644 --- a/packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js +++ b/packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js @@ -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,