Skip to content

Commit

Permalink
* MDF [mqtt] delete debugging logs & switch to new logging api
Browse files Browse the repository at this point in the history
Signed-off-by: jaylin <[email protected]>
  • Loading branch information
JaylinYu committed Jan 4, 2024
1 parent 0bdc703 commit d7c16e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 46 deletions.
31 changes: 1 addition & 30 deletions src/mqtt/protocol/mqtt/mqtt_quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 = {
Expand Down
32 changes: 16 additions & 16 deletions src/mqtt/transport/tcp/mqtt_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d7c16e6

Please sign in to comment.