Skip to content

Commit 5b03ec9

Browse files
authored
Use uniform prefix in websocket debugging. NFC (#22662)
1 parent 3f6f7a9 commit 5b03ec9

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/library_sockfs.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ addToLibrary({
3535

3636
// If debug is enabled register simple default logging callbacks for each Event.
3737
#if SOCKET_DEBUG
38-
Module['websocket']['on']('error', (error) => dbg('Socket error ' + error));
39-
Module['websocket']['on']('open', (fd) => dbg('Socket open fd = ' + fd));
40-
Module['websocket']['on']('listen', (fd) => dbg('Socket listen fd = ' + fd));
41-
Module['websocket']['on']('connection', (fd) => dbg('Socket connection fd = ' + fd));
42-
Module['websocket']['on']('message', (fd) => dbg('Socket message fd = ' + fd));
43-
Module['websocket']['on']('close', (fd) => dbg('Socket close fd = ' + fd));
38+
Module['websocket']['on']('error', (error) => dbg('websocket: error ' + error));
39+
Module['websocket']['on']('open', (fd) => dbg('websocket: open fd = ' + fd));
40+
Module['websocket']['on']('listen', (fd) => dbg('websocket: listen fd = ' + fd));
41+
Module['websocket']['on']('connection', (fd) => dbg('websocket: connection fd = ' + fd));
42+
Module['websocket']['on']('message', (fd) => dbg('websocket: message fd = ' + fd));
43+
Module['websocket']['on']('close', (fd) => dbg('websocket: close fd = ' + fd));
4444
#endif
4545

4646
return FS.createNode(null, '/', {{{ cDefs.S_IFDIR }}} | 511 /* 0777 */, 0);
@@ -214,7 +214,7 @@ addToLibrary({
214214
}
215215

216216
#if SOCKET_DEBUG
217-
dbg('connect: ' + url + ', ' + subProtocols.toString());
217+
dbg('websocket: connect: ' + url + ', ' + subProtocols.toString());
218218
#endif
219219
// If node we use the ws library.
220220
var WebSocketConstructor;
@@ -234,7 +234,7 @@ addToLibrary({
234234
}
235235

236236
#if SOCKET_DEBUG
237-
dbg('websocket adding peer: ' + addr + ':' + port);
237+
dbg('websocket: adding peer: ' + addr + ':' + port);
238238
#endif
239239

240240
var peer = {
@@ -252,7 +252,7 @@ addToLibrary({
252252
// remote end.
253253
if (sock.type === {{{ cDefs.SOCK_DGRAM }}} && typeof sock.sport != 'undefined') {
254254
#if SOCKET_DEBUG
255-
dbg('websocket queuing port message (port ' + sock.sport + ')');
255+
dbg('websocket: queuing port message (port ' + sock.sport + ')');
256256
#endif
257257
peer.dgram_send_queue.push(new Uint8Array([
258258
255, 255, 255, 255,
@@ -277,7 +277,7 @@ addToLibrary({
277277

278278
var handleOpen = function () {
279279
#if SOCKET_DEBUG
280-
dbg('websocket handle open');
280+
dbg('websocket: handle open');
281281
#endif
282282

283283
Module['websocket'].emit('open', sock.stream.fd);
@@ -286,7 +286,7 @@ addToLibrary({
286286
var queued = peer.dgram_send_queue.shift();
287287
while (queued) {
288288
#if SOCKET_DEBUG
289-
dbg('websocket sending queued data (' + queued.byteLength + ' bytes): ' + [Array.prototype.slice.call(new Uint8Array(queued))]);
289+
dbg('websocket: sending queued data (' + queued.byteLength + ' bytes): ' + [Array.prototype.slice.call(new Uint8Array(queued))]);
290290
#endif
291291
peer.socket.send(queued);
292292
queued = peer.dgram_send_queue.shift();
@@ -314,7 +314,7 @@ addToLibrary({
314314
}
315315

316316
#if SOCKET_DEBUG
317-
dbg('websocket handle message (' + data.byteLength + ' bytes): ' + [Array.prototype.slice.call(data)]);
317+
dbg('websocket: handle message (' + data.byteLength + ' bytes): ' + [Array.prototype.slice.call(data)]);
318318
#endif
319319

320320
// if this is the port message, override the peer's port with it
@@ -507,7 +507,7 @@ addToLibrary({
507507
var WebSocketServer = require('ws').Server;
508508
var host = sock.saddr;
509509
#if SOCKET_DEBUG
510-
dbg('listen: ' + host + ':' + sock.sport);
510+
dbg('websocket: listen: ' + host + ':' + sock.sport);
511511
#endif
512512
sock.server = new WebSocketServer({
513513
host,
@@ -518,7 +518,7 @@ addToLibrary({
518518

519519
sock.server.on('connection', function(ws) {
520520
#if SOCKET_DEBUG
521-
dbg('received connection from: ' + ws._socket.remoteAddress + ':' + ws._socket.remotePort);
521+
dbg('websocket: received connection from: ' + ws._socket.remoteAddress + ':' + ws._socket.remotePort);
522522
#endif
523523
if (sock.type === {{{ cDefs.SOCK_STREAM }}}) {
524524
var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
@@ -641,7 +641,7 @@ addToLibrary({
641641
dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
642642
}
643643
#if SOCKET_DEBUG
644-
dbg('websocket queuing (' + length + ' bytes): ' + [Array.prototype.slice.call(new Uint8Array(data))]);
644+
dbg('websocket: queuing (' + length + ' bytes): ' + [Array.prototype.slice.call(new Uint8Array(data))]);
645645
#endif
646646
dest.dgram_send_queue.push(data);
647647
return length;
@@ -650,7 +650,7 @@ addToLibrary({
650650

651651
try {
652652
#if SOCKET_DEBUG
653-
dbg('websocket send (' + length + ' bytes): ' + [Array.prototype.slice.call(new Uint8Array(data))]);
653+
dbg('websocket: send (' + length + ' bytes): ' + [Array.prototype.slice.call(new Uint8Array(data))]);
654654
#endif
655655
// send the actual data
656656
dest.socket.send(data);
@@ -698,14 +698,14 @@ addToLibrary({
698698
};
699699

700700
#if SOCKET_DEBUG
701-
dbg('websocket read (' + bytesRead + ' bytes): ' + [Array.prototype.slice.call(res.buffer)]);
701+
dbg('websocket: read (' + bytesRead + ' bytes): ' + [Array.prototype.slice.call(res.buffer)]);
702702
#endif
703703

704704
// push back any unread data for TCP connections
705705
if (sock.type === {{{ cDefs.SOCK_STREAM }}} && bytesRead < queuedLength) {
706706
var bytesRemaining = queuedLength - bytesRead;
707707
#if SOCKET_DEBUG
708-
dbg('websocket read: put back ' + bytesRemaining + ' bytes');
708+
dbg('websocket: read: put back ' + bytesRemaining + ' bytes');
709709
#endif
710710
queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
711711
sock.recv_queue.unshift(queued);

0 commit comments

Comments
 (0)