Socket.IO is now completely instrumented by a minimalistic yet tremendously powerful utility called debug by TJ Holowaychuk.
Before 1.0, the Socket.IO server would default to logging everything out to the console. This turned out to be annoyingly verbose for many users (although extremely useful for others), so now we default to being completely silent by default.
The basic idea is that each module used by Socket.IO provides different debugging scopes that give you insight into the internals. By default, all output is suppressed, and you can opt into seeing messages by supplying the DEBUG
env variable (Node.JS) or the localStorage.debug
property (Browsers).
You can see it in action for example on our homepage:
Socket.IO现在完全由TJ Holowaychuk称为debug的简约但功能强大的实用程序完成。
在1.0之前,Socket.IO服务器将默认将所有内容注销到控制台。 事实证明,这对于许多用户来说是非常烦人的(尽管对其他用户而言非常有用),因此现在默认情况下,我们默认为完全静音。
基本思想是Socket.IO使用的每个模块都提供不同的调试作用域,使您可以深入了解内部。 默认情况下,所有输出都是禁止的,您可以通过提供DEBUG env变量(Node.JS)或localStorage.debug属性(浏览器)来选择查看消息。
您可以在我们的主页上看到它的实际运行情况:
Available debugging scopes
The best way to see what information is available is to use the *
:
1 | DEBUG=* node yourfile.js |
or in the browser:
1 | localStorage.debug = '*'; |
And then filter by the scopes you’re interested in. You can prefix the *
with scopes, separated by comma if there is more than one. For example, to only see debug statements from the socket.io client on Node.js try this:
然后按感兴趣的范围进行过滤。您可以在*前面加上范围,如果有多个,则以逗号分隔。 例如,要仅查看Node.js上来自socket.io客户端的调试语句,请尝试以下操作:
1 | DEBUG=socket.io:client* node yourfile.js |
To see all debug messages from the engine and socket.io:
要查看来自engine和socket.io的所有调试消息:
1 | DEBUG=engine,socket.io* node yourfile.js |
Caught a mistake? Edit this page on GitHub