Skip to content

Commit d1b750d

Browse files
TimothyGutargos
authored andcommitted
inspector: add debugging for WebSocket messages
PR-URL: #21473 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 7d2fe5d commit d1b750d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/env.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,10 @@ struct ContextInfo {
415415
};
416416

417417
// Listing the AsyncWrap provider types first enables us to cast directly
418-
// from a provider type to a debug category. Currently no other debug
419-
// categories are available.
418+
// from a provider type to a debug category.
420419
#define DEBUG_CATEGORY_NAMES(V) \
421-
NODE_ASYNC_PROVIDER_TYPES(V)
420+
NODE_ASYNC_PROVIDER_TYPES(V) \
421+
V(INSPECTOR_SERVER)
422422

423423
enum class DebugCategory {
424424
#define V(name) name,

src/inspector_io.cc

+6
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ void InspectorIo::SwapBehindLock(MessageQueue<ActionType>* vector1,
314314

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

396398
void InspectorIo::Write(TransportAction action, int session_id,
397399
const StringView& inspector_message) {
400+
std::string message_str =
401+
protocol::StringUtil::StringViewToUtf8(inspector_message);
402+
Debug(parent_env_, DebugCategory::INSPECTOR_SERVER,
403+
"<<< %s\n", message_str.c_str());
398404
AppendMessage(&outgoing_message_queue_, action, session_id,
399405
StringBuffer::create(inspector_message));
400406
int err = uv_async_send(&thread_req_);

0 commit comments

Comments
 (0)