From 48791bcd9873b4db10435077c0560907fdb263b2 Mon Sep 17 00:00:00 2001 From: Matt Blagden Date: Tue, 27 Jun 2023 10:44:42 -0700 Subject: [PATCH] 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 --- .../ReactCommon/hermes/inspector/chrome/Connection.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native/ReactCommon/hermes/inspector/chrome/Connection.cpp b/packages/react-native/ReactCommon/hermes/inspector/chrome/Connection.cpp index 4bc2a2b2dcc..eb548df0bdd 100644 --- a/packages/react-native/ReactCommon/hermes/inspector/chrome/Connection.cpp +++ b/packages/react-native/ReactCommon/hermes/inspector/chrome/Connection.cpp @@ -421,6 +421,10 @@ void Connection::Impl::onMessageAdded( const ConsoleMessageInfo &info) { m::runtime::ConsoleAPICalledNotification apiCalledNote; apiCalledNote.type = info.level; + apiCalledNote.timestamp = + std::chrono::duration>( + std::chrono::system_clock::now().time_since_epoch()) + .count(); // TODO(jpporto): fix test cases sending invalid context id. // apiCalledNote.executionContextId = kHermesExecutionContextId;