Only log data at TCP level if flag is DEBUG

pull/17861/head
Yash Tibrewal 6 years ago
parent 425693696d
commit b9804c30fe
  1. 27
      src/core/lib/iomgr/tcp_posix.cc

@ -408,13 +408,15 @@ static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
gpr_log(GPR_INFO, "TCP:%p call_cb %p %p:%p", tcp, cb, cb->cb, cb->cb_arg); gpr_log(GPR_INFO, "TCP:%p call_cb %p %p:%p", tcp, cb, cb->cb, cb->cb_arg);
size_t i; size_t i;
const char* str = grpc_error_string(error); const char* str = grpc_error_string(error);
gpr_log(GPR_INFO, "read: error=%s", str); gpr_log(GPR_INFO, "READ %p (peer=%s) error=%s", tcp, tcp->peer_string, str);
for (i = 0; i < tcp->incoming_buffer->count; i++) { if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
char* dump = grpc_dump_slice(tcp->incoming_buffer->slices[i], for (i = 0; i < tcp->incoming_buffer->count; i++) {
GPR_DUMP_HEX | GPR_DUMP_ASCII); char* dump = grpc_dump_slice(tcp->incoming_buffer->slices[i],
gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump); GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_free(dump); gpr_log(GPR_DEBUG, "DATA: %s", dump);
gpr_free(dump);
}
} }
} }
@ -976,10 +978,13 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
size_t i; size_t i;
for (i = 0; i < buf->count; i++) { for (i = 0; i < buf->count; i++) {
char* data = gpr_log(GPR_INFO, "WRITE %p (peer=%s)", tcp, tcp->peer_string);
grpc_dump_slice(buf->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string, data); char* data =
gpr_free(data); grpc_dump_slice(buf->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "DATA: %s", data);
gpr_free(data);
}
} }
} }

Loading…
Cancel
Save