From d7c16e6bce2a78e17b04c5ceb70590bf110fad0b Mon Sep 17 00:00:00 2001 From: jaylin Date: Tue, 2 Jan 2024 19:21:05 +0800 Subject: [PATCH] * MDF [mqtt] delete debugging logs & switch to new logging api Signed-off-by: jaylin --- src/mqtt/protocol/mqtt/mqtt_quic.c | 31 +---------------------------- src/mqtt/transport/tcp/mqtt_tcp.c | 32 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 46 deletions(-) diff --git a/src/mqtt/protocol/mqtt/mqtt_quic.c b/src/mqtt/protocol/mqtt/mqtt_quic.c index 105bd3fe..94116e33 100644 --- a/src/mqtt/protocol/mqtt/mqtt_quic.c +++ b/src/mqtt/protocol/mqtt/mqtt_quic.c @@ -13,6 +13,7 @@ #include "nng/mqtt/mqtt_quic.h" #include "sqlite_handler.h" #include "core/nng_impl.h" +#include "nng/supplemental/nanolib/log.h" #include "supplemental/mqtt/mqtt_msg.h" #include "supplemental/mqtt/mqtt_qos_db_api.h" #include "supplemental/quic/quic_api.h" @@ -55,36 +56,6 @@ static int mqtt_sub_stream(mqtt_pipe_t *p, nni_msg *msg, uint64_t packet_id, nni static void *mqtt_quic_sock_get_sqlite_option(mqtt_sock_t *s); #endif -#define MQTT_PROTOCOL_DEBUG 0 - -#if MQTT_PROTOCOL_DEBUG -#define log_info(fmt, ...) \ - do { \ - printf("[%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ - } while (0) - -#define log_warn(fmt, ...) \ - do { \ - printf("[%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ - } while (0) - -#define log_debug(fmt, ...) \ - do { \ - printf("[%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ - } while (0) - -#define log_error(fmt, ...) \ - do { \ - printf("[%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ - } while (0) -#else -#define qdebug(fmt, ...) do {} while(0) -#define log_debug(fmt, ...) do {} while(0) -#define log_info(fmt, ...) do {} while(0) -#define log_warn(fmt, ...) do {} while(0) -#define log_error(fmt, ...) do {} while(0) -#endif - //default QUIC config for define QUIC transport static conf_quic config_default = { .tls = { diff --git a/src/mqtt/transport/tcp/mqtt_tcp.c b/src/mqtt/transport/tcp/mqtt_tcp.c index d1d9eea6..802559d0 100644 --- a/src/mqtt/transport/tcp/mqtt_tcp.c +++ b/src/mqtt/transport/tcp/mqtt_tcp.c @@ -916,26 +916,26 @@ mqtt_tcptran_pipe_send_start(mqtt_tcptran_pipe *p) niov++; } - int msg_body_len = 30 < nni_msg_len(msg) ? 30 : nni_msg_len(msg); + // int msg_body_len = 30 < nni_msg_len(msg) ? 30 : nni_msg_len(msg); - char *strheader = nng_alloc(nni_msg_header_len(msg) * 3 + 1); - char *strbody = nng_alloc(msg_body_len * 3 + 1); - char *data; + // char *strheader = nng_alloc(nni_msg_header_len(msg) * 3 + 1); + // char *strbody = nng_alloc(msg_body_len * 3 + 1); + // char *data; - data = nni_msg_header(msg); - for (int i = 0; i < nni_msg_header_len(msg); ++i) { - sprintf(strheader + i * 3, "%02X ", data[i]); - } - log_debug("msg header: %s", strheader); + // data = nni_msg_header(msg); + // for (int i = 0; i < nni_msg_header_len(msg); ++i) { + // sprintf(strheader + i * 3, "%02X ", data[i]); + // } + // log_debug("msg header: %s", strheader); - data = nni_msg_body(msg); - for (int i = 0; i < msg_body_len; ++i) { - sprintf(strbody + i * 3, "%02X ", data[i]); - } - log_debug("msg body: %s", strbody); + // data = nni_msg_body(msg); + // for (int i = 0; i < msg_body_len; ++i) { + // sprintf(strbody + i * 3, "%02X ", data[i]); + // } + // log_debug("msg body: %s", strbody); - nng_free(strheader, nni_msg_header_len(msg) * 3 + 1); - nng_free(strbody, msg_body_len * 3 + 1); + // nng_free(strheader, nni_msg_header_len(msg) * 3 + 1); + // nng_free(strbody, msg_body_len * 3 + 1); nni_aio_set_iov(txaio, niov, iov); nng_stream_send(p->conn, txaio);