Skip to content

Commit

Permalink
inspector: log response and requests in the inspector for debugging
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
joyeecheung authored and danielleadams committed Jul 6, 2023
1 parent 395c56b commit 70c0e88
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/inspector_agent.cc
Expand Up @@ -245,6 +245,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));
Expand Down Expand Up @@ -293,6 +296,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);
}

Expand Down

0 comments on commit 70c0e88

Please sign in to comment.