From 54eb7bbf19f8603824caccb9e226bab4f8e61d66 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 3 Mar 2023 19:13:28 +0100 Subject: [PATCH 1/2] 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. --- src/inspector_agent.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index ad193d477a5a5c..c6a1e2f9efb053 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -248,6 +248,9 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, void dispatchProtocolMessage(const StringView& message) { std::string raw_message = protocol::StringUtil::StringViewToUtf8(message); + per_process::Debug(DebugCategory::INSPECTOR_SERVER, + "[inspector received] %s\n", + raw_message.c_str()); std::unique_ptr value = protocol::DictionaryValue::cast(protocol::StringUtil::parseMessage( raw_message, false)); @@ -296,6 +299,13 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, void flushProtocolNotifications() override { } void sendMessageToFrontend(const StringView& message) { + if (per_process::enabled_debug_list.enabled( + DebugCategory::INSPECTOR_SERVER)) { + std::string raw_message = protocol::StringUtil::StringViewToUtf8(message); + per_process::Debug(DebugCategory::INSPECTOR_SERVER, + "[inspector send] %s\n", + raw_message.c_str()); + } delegate_->SendMessageToFrontend(message); } From 5179c818d9787f7699fea19aba1931ec03599498 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 6 Mar 2023 00:08:22 +0100 Subject: [PATCH 2/2] fixup! inspector: log response and requests in the inspector for debugging Co-authored-by: Anna Henningsen --- src/inspector_agent.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index c6a1e2f9efb053..ea6a03819cc7b9 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -250,7 +250,7 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, std::string raw_message = protocol::StringUtil::StringViewToUtf8(message); per_process::Debug(DebugCategory::INSPECTOR_SERVER, "[inspector received] %s\n", - raw_message.c_str()); + raw_message); std::unique_ptr value = protocol::DictionaryValue::cast(protocol::StringUtil::parseMessage( raw_message, false)); @@ -304,7 +304,7 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel, std::string raw_message = protocol::StringUtil::StringViewToUtf8(message); per_process::Debug(DebugCategory::INSPECTOR_SERVER, "[inspector send] %s\n", - raw_message.c_str()); + raw_message); } delegate_->SendMessageToFrontend(message); }