From 0ed6b39b28be75e395e9c7b3bb02cce378caba4e Mon Sep 17 00:00:00 2001 From: eeff <33566201+eeff@users.noreply.github.com> Date: Thu, 30 Jun 2022 18:21:45 +0800 Subject: [PATCH] feat(restful): enable websocket logging --- plugins/restful/rest.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/restful/rest.c b/plugins/restful/rest.c index 2cbe3d2e..e2361f10 100644 --- a/plugins/restful/rest.c +++ b/plugins/restful/rest.c @@ -35,6 +35,7 @@ #include "rw_handle.h" #include "utils/log.h" #include "utils/neu_jwt.h" +#include "websocket.h" #include "json/neu_json_fn.h" #define neu_plugin_module default_dashboard_plugin_module @@ -174,9 +175,17 @@ static neu_plugin_t *dashb_plugin_open(void) goto web_server_start_fail; } + rv = log_websocket_start("ws://0.0.0.0:7001/log"); + if (0 != rv) { + nlog_error("Failed to start log websocket"); + goto log_websocket_start_fail; + } + nlog_info("Success to create plugin: %s", neu_plugin_module.module_name); return plugin; +log_websocket_start_fail: + nng_http_server_stop(plugin->web_server); web_server_start_fail: nng_http_server_stop(plugin->api_server); api_server_start_fail: @@ -198,6 +207,7 @@ static int dashb_plugin_close(neu_plugin_t *plugin) nlog_info("Success to before free plugin: %s", neu_plugin_module.module_name); + log_websocket_stop(); nng_http_server_stop(plugin->api_server); nng_http_server_release(plugin->api_server); nng_http_server_stop(plugin->web_server);