在 jhipster 中禁用 stomp 调试输出

disable stomp debug output in jhipster

我在这里坐了几个小时来了解如何禁用 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

有没有办法关闭它?

..

感谢您的帮助!

您可以通过在声明 this.stompClient 的任何位置声明 this.stompClient.debug = () => {} 来禁用 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:

的更多信息

The client can set its debug property to a function which takes a String argument to see all the debug statements of the library:

By default, the debug messages are logged in the browser window's console.

Can also be pass as an argument

const socket: WebSocket = new SockJS(url);
this.stompClient = Stomp.over(socket, { debug: false });
...