javascript 如何在 sockjs-STOMP 上禁用调试消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25683022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable debug messages on sockjs- STOMP
提问by J.R.
I have the follow situation:
我有以下情况:
var options = {
protocols_whitelist : [ "websocket", "xhr-streaming", "xdr-streaming", "xhr-polling", "xdr-polling", "iframe-htmlfile", "iframe-eventsource", "iframe-xhr-polling" ],
debug : false
};
var socket = new SockJS("/mmyurl/",undefined,options);
var stompClient = Stomp.over(socket);
stompClient.connect({
company : "XXXXX"
}, function(frame) {
stompClient.subscribe('/topic/mytopic', function(message){
var myitem = JSON.parse(message.body);
});
all works fine, the problem is that on the javascript console is full of debug messages like this:
一切正常,问题是在 javascript 控制台上充满了这样的调试消息:
<<< MESSAGE
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:o6g660dt-113
destination:/topic/mytopic
content-length:411
And I want to disable the messages.
我想禁用这些消息。
I tried to change some option and also tried to register simply:
我试图改变一些选项,也试图简单地注册:
var socket = new SockJS("/mmyurl/");
but it doesn't work.
但它不起作用。
Is there a way to disable the debug messages?
有没有办法禁用调试消息?
Any help is appreciated
任何帮助表示赞赏
回答by J.R.
Ok I found a solution.
好的,我找到了解决方案。
I added this code:
我添加了这个代码:
stompClient.debug = null
In this way, the debug function is disabled.
这样,调试功能被禁用。
回答by PaulB
I tried JR's answer but started receiving errors (was using redux sagas) - changing debug to an empty function worked ...
我尝试了 JR 的答案,但开始收到错误(正在使用 redux sagas)-将调试更改为空函数有效......
stompClient.debug = () => {};