From fabf135c7f43f22e79dcb47fd0adf42cb3f64bc1 Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:06:43 -0700 Subject: [PATCH] [Gpr_To_Absl_Logging] Replace gpr_should_log with ABSL_VLOG_IS_ON (#36866) [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 #36866 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36866 from tanvi-jagtap:fix_secure_endpoint_gpr_should 556006c720ffdf6247d174065c9970092be4cf9e PiperOrigin-RevId: 641939641 --- src/core/handshaker/security/secure_endpoint.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/handshaker/security/secure_endpoint.cc b/src/core/handshaker/security/secure_endpoint.cc index 2ca7e6773e2..18fde152438 100644 --- a/src/core/handshaker/security/secure_endpoint.cc +++ b/src/core/handshaker/security/secure_endpoint.cc @@ -26,6 +26,7 @@ #include "absl/base/thread_annotations.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" @@ -232,13 +233,12 @@ static void flush_read_staging_buffer(secure_endpoint* ep, uint8_t** cur, } static void call_read_cb(secure_endpoint* ep, grpc_error_handle error) { - if (GRPC_TRACE_FLAG_ENABLED(secure_endpoint) && - gpr_should_log(GPR_LOG_SEVERITY_INFO)) { + if (GRPC_TRACE_FLAG_ENABLED(secure_endpoint) && ABSL_VLOG_IS_ON(2)) { size_t i; for (i = 0; i < ep->read_buffer->count; i++) { char* data = grpc_dump_slice(ep->read_buffer->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_INFO, "READ %p: %s", ep, data); + VLOG(2) << "READ " << ep << ": " << data; gpr_free(data); } } @@ -400,12 +400,11 @@ static void endpoint_write(grpc_endpoint* secure_ep, grpc_slice_buffer* slices, grpc_slice_buffer_reset_and_unref(&ep->output_buffer); - if (GRPC_TRACE_FLAG_ENABLED(secure_endpoint) && - gpr_should_log(GPR_LOG_SEVERITY_INFO)) { + if (GRPC_TRACE_FLAG_ENABLED(secure_endpoint) && ABSL_VLOG_IS_ON(2)) { 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: %s", ep, data); + VLOG(2) << "WRITE " << ep << ": " << data; gpr_free(data); } }