connection: add send log

This commit is contained in:
fengzero
2022-06-21 02:08:00 +00:00
parent dba6ea7459
commit 11788dab41
2 changed files with 12 additions and 0 deletions
+11
View File
@@ -86,4 +86,15 @@ extern zlog_category_t *neuron;
} \
plog_debug(plugin, "%s", protocol_buf);
#define zlog_recv_protocol(log, bytes, n_byte) \
char protocol_buf[2048] = { 0 }; \
int offset = 0; \
offset = snprintf(protocol_buf, sizeof(protocol_buf), "<<"); \
for (int i = 0; i < n_byte; i++) { \
offset += \
snprintf(protocol_buf + offset, sizeof(protocol_buf) - offset, \
" 0x%02hhX", bytes[i]); \
} \
zlog_debug(log, "%s", protocol_buf);
#endif
+1
View File
@@ -769,6 +769,7 @@ void neu_conn_stream_consume(neu_conn_t *conn, void *context,
ssize_t ret =
neu_conn_recv(conn, recv_buf + offset, sizeof(recv_buf) - offset);
if (ret > 0) {
zlog_recv_protocol(conn->param.log, recv_buf + offset, ret);
offset += ret;
neu_protocol_unpack_buf_t protocol_buf = { 0 };
neu_protocol_unpack_buf_init(&protocol_buf, recv_buf, offset);