我坐在这里几个小时,以了解如何禁用stomp.js的调试输出。
我实际上是在开发+生产环境中获得此输出:
Web Socket Opened...
webstomp.js?afe9:238 >>> CONNECT
accept-version:1.2,1.1,1.0
heart-beat:10000,10000
�
webstomp.js?afe9:238 >>> length 60
webstomp.js?afe9:238 <<< CONNECTED
version:1.2
heart-beat:0,0
user-name:coach
�
webstomp.js?afe9:238 connected to server undefined
webstomp.js?afe9:238 >>> SEND
destination:/topic/activity
content-length:12
{"page":"/"}�
webstomp.js?afe9:238 >>> length 65
webstomp.js?afe9:238 >>> SEND
destination:/topic/activity
content-length:35
{"page":"/coach/client-management"}�
webstomp.js?afe9:238 >>> length 88
有没有办法将其关闭?
...
感谢您的帮助!
答案 0 :(得分:2)
您可以通过在声明this.stompClient.debug = () => {}
的任何地方声明this.stompClient
来禁用stomp调试方法。默认情况下,JHipster应用程序位于src/main/webapp/app/core/tracker/TrackerService.js
const socket = new SockJS(url);
this.stompClient = Stomp.over(socket);
// add this line
this.stompClient.debug = () => {}
const headers = {};
this.stompClient.connect(headers, () => {
....
您可以找到有关如何使用debug method in the STOMP docs:
的更多信息客户端可以将其debug属性设置为一个函数,该函数接受String参数以查看库的所有调试语句:
默认情况下,调试消息会记录在浏览器窗口的控制台中。
答案 1 :(得分:0)
也可以作为参数传递
const socket: WebSocket = new SockJS(url); this.stompClient = Stomp.over(socket, { debug: false }); ...