Fix grouping of console logs (#37835)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37835

Chrome Dev Tools doesn't correctly display grouped console logs (i.e. console output between a `console.group` and `console.groupEnd`) when timestamps are all zero.

Populate the timestamp field so grouping functions as expected.

Changelog: [General] [Fixed] Fix timestamps and grouped display of console messages within in a `console.group`

Reviewed By: fbmal7

Differential Revision: D46605659

fbshipit-source-id: c5821bfb4807c7f0ce28b7bb95ea08de29caf8a2
This commit is contained in:
Matt Blagden 2023-06-27 10:44:42 -07:00 committed by Facebook GitHub Bot
parent 37460b06a4
commit 48791bcd98

View File

@ -421,6 +421,10 @@ void Connection::Impl::onMessageAdded(
const ConsoleMessageInfo &info) {
m::runtime::ConsoleAPICalledNotification apiCalledNote;
apiCalledNote.type = info.level;
apiCalledNote.timestamp =
std::chrono::duration<double, std::ratio<1, 1000>>(
std::chrono::system_clock::now().time_since_epoch())
.count();
// TODO(jpporto): fix test cases sending invalid context id.
// apiCalledNote.executionContextId = kHermesExecutionContextId;