Skip to content

Commit 70c0e88

Browse files
joyeecheungdanielleadams
authored andcommittedJul 6, 2023
inspector: log response and requests in the inspector for debugging
Logs the raw messages from the inspector when NODE_DEBUG_NATIVE is set to inspector_server to facilitate debugging. PR-URL: #46941 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent 395c56b commit 70c0e88

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎src/inspector_agent.cc

+10
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
245245

246246
void dispatchProtocolMessage(const StringView& message) {
247247
std::string raw_message = protocol::StringUtil::StringViewToUtf8(message);
248+
per_process::Debug(DebugCategory::INSPECTOR_SERVER,
249+
"[inspector received] %s\n",
250+
raw_message);
248251
std::unique_ptr<protocol::DictionaryValue> value =
249252
protocol::DictionaryValue::cast(protocol::StringUtil::parseMessage(
250253
raw_message, false));
@@ -293,6 +296,13 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
293296
void flushProtocolNotifications() override { }
294297

295298
void sendMessageToFrontend(const StringView& message) {
299+
if (per_process::enabled_debug_list.enabled(
300+
DebugCategory::INSPECTOR_SERVER)) {
301+
std::string raw_message = protocol::StringUtil::StringViewToUtf8(message);
302+
per_process::Debug(DebugCategory::INSPECTOR_SERVER,
303+
"[inspector send] %s\n",
304+
raw_message);
305+
}
296306
delegate_->SendMessageToFrontend(message);
297307
}
298308

0 commit comments

Comments
 (0)
Please sign in to comment.