summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2023-03-22 10:28:02 +0100
committerGitHub <noreply@github.com>2023-03-22 09:28:02 +0000
commit434bdde97464cc04f79ed3c8398f2a50c71c39d1 (patch)
tree29206b83041cebcca0ab8b2d02f0b6c9cef31b08 /src
parentb4365c161c2dc9f04eba96b33c8f4db89f0b0d19 (diff)
downloadnode-new-434bdde97464cc04f79ed3c8398f2a50c71c39d1.tar.gz
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: https://github.com/nodejs/node/pull/46941 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/inspector_agent.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc
index 02842c7e5e..bb60e47e9d 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);
std::unique_ptr<protocol::DictionaryValue> 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);
+ }
delegate_->SendMessageToFrontend(message);
}