[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 556006c720
PiperOrigin-RevId: 641939641
pull/36729/head^2
Tanvi Jagtap 9 months ago committed by Copybara-Service
parent 203f2b4d16
commit fabf135c7f
  1. 11
      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);
}
}

Loading…
Cancel
Save