[Gpr_To_Absl_Logging] Replace gpr_should_log with ABSL_VLOG_IS_ON (#36868)
[Gpr_To_Absl_Logging] Removing instances of gpr_should_log and replacing it with ABSL_VLOG_IS_ON.
gpr_should_log function will be deleted soon.
**VLOG(2)** is equivalent to gpr_log(**GPR_DEBUG**, ... )
We are replacing two instances of **gpr_log(GPR_INFO**, ... ) with **VLOG(2)** because this code appears to be slightly expensive.
I can also continue to use LOG(INFO) and check current settings using absl::MinLogLevel() . Would you want me to do that?
Closes #36868
COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36868 from tanvi-jagtap:fix_tcp_windows_gpr_should_log c2b660d4e2
PiperOrigin-RevId: 641938430
This commit is contained in:
parent
cd595a8794
commit
42648a6fdf
|
|
@ -25,6 +25,7 @@
|
|||
#include <limits.h>
|
||||
|
||||
#include "absl/log/check.h"
|
||||
#include "absl/log/log.h"
|
||||
|
||||
#include <grpc/slice_buffer.h>
|
||||
#include <grpc/support/alloc.h>
|
||||
|
|
@ -200,14 +201,13 @@ static void on_read(void* tcpp, grpc_error_handle error) {
|
|||
}
|
||||
CHECK((size_t)info->bytes_transferred == tcp->read_slices->length);
|
||||
|
||||
if (GRPC_TRACE_FLAG_ENABLED(tcp) &&
|
||||
gpr_should_log(GPR_LOG_SEVERITY_INFO)) {
|
||||
if (GRPC_TRACE_FLAG_ENABLED(tcp) && ABSL_VLOG_IS_ON(2)) {
|
||||
size_t i;
|
||||
for (i = 0; i < tcp->read_slices->count; i++) {
|
||||
char* dump = grpc_dump_slice(tcp->read_slices->slices[i],
|
||||
GPR_DUMP_HEX | GPR_DUMP_ASCII);
|
||||
gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp,
|
||||
tcp->peer_string.c_str(), dump);
|
||||
VLOG(2) << "READ " << tcp << " (peer=" << tcp->peer_string
|
||||
<< "): " << dump;
|
||||
gpr_free(dump);
|
||||
}
|
||||
}
|
||||
|
|
@ -350,13 +350,13 @@ static void win_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
|
|||
WSABUF* buffers = local_buffers;
|
||||
size_t len, async_buffers_offset = 0;
|
||||
|
||||
if (GRPC_TRACE_FLAG_ENABLED(tcp) && gpr_should_log(GPR_LOG_SEVERITY_INFO)) {
|
||||
if (GRPC_TRACE_FLAG_ENABLED(tcp) && ABSL_VLOG_IS_ON(2)) {
|
||||
size_t i;
|
||||
for (i = 0; i < slices->count; i++) {
|
||||
char* data =
|
||||
grpc_dump_slice(slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
|
||||
gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string.c_str(),
|
||||
data);
|
||||
VLOG(2) << "WRITE " << tcp << " (peer=" << tcp->peer_string
|
||||
<< "): " << data;
|
||||
gpr_free(data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue