Skip to content

Commit

Permalink
inspector: add debugging for WebSocket messages
Browse files Browse the repository at this point in the history
PR-URL: #21473
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
TimothyGu committed Jun 26, 2018
1 parent 65f6173 commit 8836a0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ struct ContextInfo {
};

// Listing the AsyncWrap provider types first enables us to cast directly
// from a provider type to a debug category. Currently no other debug
// categories are available.
// from a provider type to a debug category.
#define DEBUG_CATEGORY_NAMES(V) \
NODE_ASYNC_PROVIDER_TYPES(V)
NODE_ASYNC_PROVIDER_TYPES(V) \
V(INSPECTOR_SERVER)

enum class DebugCategory {
#define V(name) name,
Expand Down
6 changes: 6 additions & 0 deletions src/inspector_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ void InspectorIo::SwapBehindLock(MessageQueue<ActionType>* vector1,

void InspectorIo::PostIncomingMessage(InspectorAction action, int session_id,
const std::string& message) {
Debug(parent_env_, DebugCategory::INSPECTOR_SERVER,
">>> %s\n", message.c_str());
if (AppendMessage(&incoming_message_queue_, action, session_id,
Utf8ToStringView(message))) {
Agent* agent = main_thread_req_->second;
Expand Down Expand Up @@ -395,6 +397,10 @@ void InspectorIo::MainThreadReqAsyncCb(uv_async_t* req) {

void InspectorIo::Write(TransportAction action, int session_id,
const StringView& inspector_message) {
std::string message_str =
protocol::StringUtil::StringViewToUtf8(inspector_message);
Debug(parent_env_, DebugCategory::INSPECTOR_SERVER,
"<<< %s\n", message_str.c_str());
AppendMessage(&outgoing_message_queue_, action, session_id,
StringBuffer::create(inspector_message));
int err = uv_async_send(&thread_req_);
Expand Down

0 comments on commit 8836a0d

Please sign in to comment.