English 中文(简体)
Socket.IO - Logging & Debugging
  • 时间:2024-12-22

Socket.IO - Logging & Debugging


Previous Page Next Page  

Socket.IO uses a very famous debugging module developed by ExpresJS s main author, called debug. Earper Socket.IO used to log everything to the console making it quite difficult to debug the problem. After the v1.0 release, you can specify what you want to log.

Server-side

The best way to see what information is available is to use the * −


DEBUG=* node app.js

This will colorize and output everything that happens to your server console. For example, we can consider the following screenshot.

Logging Example

Cpent-side

Paste this to console, cpck enter and refresh your page. This will again output everything related to Socket.io to your console.


localStorage.debug =  * ;

You can pmit the output to get the debug info with incoming data from the socket using the following command.


localStorage.debug =  socket.io-cpent:socket ;

You can see the result pke the following screenshot, if you use the second statement to log the info −

Cpent Logging

There is a very good blog post related to socket.io debugging here.

Advertisements