Skip to content

Commit e33dfce

Browse files
joyeecheungRafaelGSS
authored andcommitted
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 <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent 77f7200 commit e33dfce

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
@@ -248,6 +248,9 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
248248

249249
void dispatchProtocolMessage(const StringView& message) {
250250
std::string raw_message = protocol::StringUtil::StringViewToUtf8(message);
251+
per_process::Debug(DebugCategory::INSPECTOR_SERVER,
252+
"[inspector received] %s\n",
253+
raw_message);
251254
std::unique_ptr<protocol::DictionaryValue> value =
252255
protocol::DictionaryValue::cast(protocol::StringUtil::parseMessage(
253256
raw_message, false));
@@ -296,6 +299,13 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
296299
void flushProtocolNotifications() override { }
297300

298301
void sendMessageToFrontend(const StringView& message) {
302+
if (per_process::enabled_debug_list.enabled(
303+
DebugCategory::INSPECTOR_SERVER)) {
304+
std::string raw_message = protocol::StringUtil::StringViewToUtf8(message);
305+
per_process::Debug(DebugCategory::INSPECTOR_SERVER,
306+
"[inspector send] %s\n",
307+
raw_message);
308+
}
299309
delegate_->SendMessageToFrontend(message);
300310
}
301311

0 commit comments

Comments
 (0)