Only log data at TCP level if flag is DEBUG

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

@ -408,15 +408,17 @@ 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);
if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
for (i = 0; i < tcp->incoming_buffer->count; i++) { for (i = 0; i < tcp->incoming_buffer->count; i++) {
char* dump = grpc_dump_slice(tcp->incoming_buffer->slices[i], char* dump = grpc_dump_slice(tcp->incoming_buffer->slices[i],
GPR_DUMP_HEX | GPR_DUMP_ASCII); GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump); gpr_log(GPR_DEBUG, "DATA: %s", dump);
gpr_free(dump); gpr_free(dump);
} }
} }
}
tcp->read_cb = nullptr; tcp->read_cb = nullptr;
tcp->incoming_buffer = nullptr; tcp->incoming_buffer = nullptr;
@ -976,12 +978,15 @@ 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++) {
gpr_log(GPR_INFO, "WRITE %p (peer=%s)", tcp, tcp->peer_string);
if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
char* data = char* data =
grpc_dump_slice(buf->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); grpc_dump_slice(buf->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string, data); gpr_log(GPR_DEBUG, "DATA: %s", data);
gpr_free(data); gpr_free(data);
} }
} }
}
GPR_ASSERT(tcp->write_cb == nullptr); GPR_ASSERT(tcp->write_cb == nullptr);

Loading…
Cancel
Save