Skip to content

Commit

Permalink
[export] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl loggi…
Browse files Browse the repository at this point in the history
…ng - gpr_log

In this CL we are migrating from gRPCs own gpr logging mechanism to absl logging mechanism. The intention is to deprecate gpr_log in the future.
We have the following mapping
1. gpr_log(GPR_INFO,...) -> LOG(INFO)
2. gpr_log(GPR_ERROR,...) -> LOG(ERROR)
3. gpr_log(GPR_DEBUG,...) -> VLOG(2)
Reviewers need to check :
1. If the above mapping is correct.
2. The content of the log is as before.
gpr_log format strings did not use string_view or std::string . absl LOG accepts these. So there will be some elimination of string_view and std::string related conversions. This is expected.

----
DO NOT SUBMIT. This PR is for testing purposes only. [cl/633802447](http://cl/633802447)

PiperOrigin-RevId: 633802447
  • Loading branch information
tanvi-jagtap authored and Copybara-Service committed May 15, 2024
1 parent befeeba commit bd6f06a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cpp/ext/csm/csm_observability.cc
Expand Up @@ -23,14 +23,14 @@
#include <utility>

#include "absl/functional/any_invocable.h"
#include "absl/log/log.h"
#include "absl/status/statusor.h"
#include "absl/types/optional.h"
#include "google/cloud/opentelemetry/resource_detector.h"
#include "opentelemetry/sdk/metrics/meter_provider.h"
#include "opentelemetry/sdk/resource/resource.h"
#include "opentelemetry/sdk/resource/resource_detector.h"

#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpcpp/ext/csm_observability.h>

Expand All @@ -56,7 +56,7 @@ bool CsmChannelTargetSelector(absl::string_view target) {
if (!g_csm_plugin_enabled) return false;
auto uri = grpc_core::URI::Parse(target);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "Failed to parse URI: %s", std::string(target).c_str());
LOG(ERROR) << "Failed to parse URI: " << target;
return false;
}
// CSM channels should have an "xds" scheme
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/server/server_context.cc
Expand Up @@ -29,6 +29,7 @@
#include <vector>

#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"

Expand All @@ -38,7 +39,6 @@
#include <grpc/load_reporting.h>
#include <grpc/status.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpcpp/completion_queue.h>
#include <grpcpp/ext/call_metric_recorder.h>
Expand Down Expand Up @@ -347,7 +347,7 @@ void ServerContextBase::TryCancel() const {
grpc_call_cancel_with_status(call_.call, GRPC_STATUS_CANCELLED,
"Cancelled on the server side", nullptr);
if (err != GRPC_CALL_OK) {
gpr_log(GPR_ERROR, "TryCancel failed with: %d", err);
LOG(ERROR) << "TryCancel failed with: " << err;
}
}

Expand Down

0 comments on commit bd6f06a

Please sign in to comment.