Skip to content

Commit

Permalink
* MDF [log] optimize format
Browse files Browse the repository at this point in the history
Signed-off-by: wayne <[email protected]>
  • Loading branch information
StargazerWayne committed Dec 29, 2023
1 parent fa607d4 commit 0113eb8
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/mqtt/transport/tcp/mqtt_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,17 +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);

Check warning on line 919 in src/mqtt/transport/tcp/mqtt_tcp.c

View check run for this annotation

Codecov / codecov/patch

src/mqtt/transport/tcp/mqtt_tcp.c#L919

Added line #L919 was not covered by tests

char *data = iov[0].iov_buf;
for (int i = 0; i < nni_msg_header_len(msg);++i) {
log_debug("msg header %d: %x", i, data[i]);
char *strheader = nng_alloc(nni_msg_header_len(msg) * 3 + 1);
char *strbody = nng_alloc(msg_body_len * 3 + 1);

Check warning on line 922 in src/mqtt/transport/tcp/mqtt_tcp.c

View check run for this annotation

Codecov / codecov/patch

src/mqtt/transport/tcp/mqtt_tcp.c#L921-L922

Added lines #L921 - L922 were not covered by tests
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]);

Check warning on line 927 in src/mqtt/transport/tcp/mqtt_tcp.c

View check run for this annotation

Codecov / codecov/patch

src/mqtt/transport/tcp/mqtt_tcp.c#L925-L927

Added lines #L925 - L927 were not covered by tests
}
log_debug("msg header: %s", strheader);

Check warning on line 929 in src/mqtt/transport/tcp/mqtt_tcp.c

View check run for this annotation

Codecov / codecov/patch

src/mqtt/transport/tcp/mqtt_tcp.c#L929

Added line #L929 was not covered by tests

data = iov[1].iov_buf;
data = nni_msg_body(msg);
for (int i = 0; i < msg_body_len; ++i) {
log_debug("msg body %d: %x", i, data[i]);
sprintf(strbody + i * 3, "%02X ", data[i]);

Check warning on line 933 in src/mqtt/transport/tcp/mqtt_tcp.c

View check run for this annotation

Codecov / codecov/patch

src/mqtt/transport/tcp/mqtt_tcp.c#L931-L933

Added lines #L931 - L933 were not covered by tests
}
log_debug("msg body: %s", strbody);

Check warning on line 935 in src/mqtt/transport/tcp/mqtt_tcp.c

View check run for this annotation

Codecov / codecov/patch

src/mqtt/transport/tcp/mqtt_tcp.c#L935

Added line #L935 was not covered by tests

nng_free(strheader, nni_msg_header_len(msg) * 3 + 1);
nng_free(strbody, msg_body_len * 3 + 1);

Check warning on line 938 in src/mqtt/transport/tcp/mqtt_tcp.c

View check run for this annotation

Codecov / codecov/patch

src/mqtt/transport/tcp/mqtt_tcp.c#L937-L938

Added lines #L937 - L938 were not covered by tests

nni_aio_set_iov(txaio, niov, iov);
nng_stream_send(p->conn, txaio);
Expand Down

0 comments on commit 0113eb8

Please sign in to comment.