[Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log

pull/37067/head
tanvi-jagtap 10 months ago
parent a11e92db6e
commit 4ddf52b071
  1. 7
      src/core/lib/event_engine/cf_engine/cf_engine.cc
  2. 9
      src/core/lib/event_engine/posix_engine/posix_engine.cc
  3. 15
      src/core/lib/event_engine/posix_engine/timer_manager.cc
  4. 8
      src/core/lib/event_engine/windows/windows_endpoint.cc
  5. 7
      src/core/lib/event_engine/windows/windows_engine.cc

@ -21,6 +21,7 @@
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/cpu.h> #include <grpc/support/cpu.h>
@ -64,9 +65,9 @@ CFEventEngine::~CFEventEngine() {
grpc_core::MutexLock lock(&task_mu_); grpc_core::MutexLock lock(&task_mu_);
if (GRPC_TRACE_FLAG_ENABLED(event_engine)) { if (GRPC_TRACE_FLAG_ENABLED(event_engine)) {
for (auto handle : known_handles_) { for (auto handle : known_handles_) {
gpr_log(GPR_ERROR, LOG(ERROR) << "CFEventEngine:" << this
"CFEventEngine:%p uncleared TaskHandle at shutdown:%s", this, << " uncleared TaskHandle at shutdown:"
HandleToString(handle).c_str()); << HandleToString(handle);
} }
} }
CHECK(GPR_LIKELY(known_handles_.empty())); CHECK(GPR_LIKELY(known_handles_.empty()));

@ -35,7 +35,6 @@
#include <grpc/event_engine/memory_allocator.h> #include <grpc/event_engine/memory_allocator.h>
#include <grpc/event_engine/slice_buffer.h> #include <grpc/event_engine/slice_buffer.h>
#include <grpc/support/cpu.h> #include <grpc/support/cpu.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/debug/trace.h" #include "src/core/lib/debug/trace.h"
@ -451,11 +450,9 @@ PosixEventEngine::~PosixEventEngine() {
grpc_core::MutexLock lock(&mu_); grpc_core::MutexLock lock(&mu_);
if (GRPC_TRACE_FLAG_ENABLED(event_engine)) { if (GRPC_TRACE_FLAG_ENABLED(event_engine)) {
for (auto handle : known_handles_) { for (auto handle : known_handles_) {
gpr_log(GPR_ERROR, LOG(ERROR) << "(event_engine) PosixEventEngine:" << this
"(event_engine) PosixEventEngine:%p uncleared " << " uncleared TaskHandle at shutdown:"
"TaskHandle at " << HandleToString(handle);
"shutdown:%s",
this, HandleToString(handle).c_str());
} }
} }
CHECK(GPR_LIKELY(known_handles_.empty())); CHECK(GPR_LIKELY(known_handles_.empty()));

@ -22,10 +22,10 @@
#include <utility> #include <utility>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/time/time.h" #include "absl/time/time.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -102,10 +102,9 @@ void TimerManager::TimerInit(Timer* timer, grpc_core::Timestamp deadline,
if (GRPC_TRACE_FLAG_ENABLED(timer)) { if (GRPC_TRACE_FLAG_ENABLED(timer)) {
grpc_core::MutexLock lock(&mu_); grpc_core::MutexLock lock(&mu_);
if (shutdown_) { if (shutdown_) {
gpr_log(GPR_ERROR, LOG(ERROR) << "WARNING: TimerManager::" << this
"WARNING: TimerManager::%p: scheduling Closure::%p after " << ": scheduling Closure::" << closure
"TimerManager has been shut down.", << " after TimerManager has been shut down.";
this, closure);
} }
} }
timer_list_->TimerInit(timer, deadline, closure); timer_list_->TimerInit(timer, deadline, closure);
@ -120,7 +119,7 @@ void TimerManager::Shutdown() {
grpc_core::MutexLock lock(&mu_); grpc_core::MutexLock lock(&mu_);
if (shutdown_) return; if (shutdown_) return;
if (GRPC_TRACE_FLAG_ENABLED(timer)) { if (GRPC_TRACE_FLAG_ENABLED(timer)) {
gpr_log(GPR_DEBUG, "TimerManager::%p shutting down", this); VLOG(2) << "TimerManager::" << this << " shutting down";
} }
shutdown_ = true; shutdown_ = true;
// Wait on the main loop to exit. // Wait on the main loop to exit.
@ -128,7 +127,7 @@ void TimerManager::Shutdown() {
} }
main_loop_exit_signal_->WaitForNotification(); main_loop_exit_signal_->WaitForNotification();
if (GRPC_TRACE_FLAG_ENABLED(timer)) { if (GRPC_TRACE_FLAG_ENABLED(timer)) {
gpr_log(GPR_DEBUG, "TimerManager::%p shutdown complete", this); VLOG(2) << "TimerManager::" << this << " shutdown complete";
} }
} }
@ -146,7 +145,7 @@ void TimerManager::RestartPostFork() {
grpc_core::MutexLock lock(&mu_); grpc_core::MutexLock lock(&mu_);
CHECK(GPR_LIKELY(shutdown_)); CHECK(GPR_LIKELY(shutdown_));
if (GRPC_TRACE_FLAG_ENABLED(timer)) { if (GRPC_TRACE_FLAG_ENABLED(timer)) {
gpr_log(GPR_DEBUG, "TimerManager::%p restarting after shutdown", this); VLOG(2) << "TimerManager::" << this << " restarting after shutdown";
} }
shutdown_ = false; shutdown_ = false;
main_loop_exit_signal_.emplace(); main_loop_exit_signal_.emplace();

@ -18,6 +18,7 @@
#include "absl/cleanup/cleanup.h" #include "absl/cleanup/cleanup.h"
#include "absl/functional/any_invocable.h" #include "absl/functional/any_invocable.h"
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -41,8 +42,7 @@ constexpr int kMaxWSABUFCount = 16;
void DumpSliceBuffer(SliceBuffer* buffer, absl::string_view context_string) { void DumpSliceBuffer(SliceBuffer* buffer, absl::string_view context_string) {
for (size_t i = 0; i < buffer->Count(); i++) { for (size_t i = 0; i < buffer->Count(); i++) {
auto str = buffer->MutableSliceAt(i).as_string_view(); auto str = buffer->MutableSliceAt(i).as_string_view();
gpr_log(GPR_INFO, "%s: %.*s", context_string.data(), str.length(), LOG(INFO) << context_string << ": " << str;
str.data());
} }
} }
@ -160,8 +160,8 @@ bool WindowsEndpoint::Write(absl::AnyInvocable<void(absl::Status)> on_writable,
if (GRPC_TRACE_FLAG_ENABLED(event_engine_endpoint_data)) { if (GRPC_TRACE_FLAG_ENABLED(event_engine_endpoint_data)) {
for (size_t i = 0; i < data->Count(); i++) { for (size_t i = 0; i < data->Count(); i++) {
auto str = data->RefSlice(i).as_string_view(); auto str = data->RefSlice(i).as_string_view();
gpr_log(GPR_INFO, "WindowsEndpoint::%p WRITE (peer=%s): %.*s", this, LOG(INFO) << "WindowsEndpoint::" << this
peer_address_string_.c_str(), str.length(), str.data()); << " WRITE (peer=" << peer_address_string_ << "): " << str;
} }
} }
CHECK(data->Count() <= UINT_MAX); CHECK(data->Count() <= UINT_MAX);

@ -218,10 +218,9 @@ WindowsEventEngine::~WindowsEventEngine() {
if (!known_handles_.empty()) { if (!known_handles_.empty()) {
if (GRPC_TRACE_FLAG_ENABLED(event_engine)) { if (GRPC_TRACE_FLAG_ENABLED(event_engine)) {
for (auto handle : known_handles_) { for (auto handle : known_handles_) {
gpr_log(GPR_ERROR, LOG(ERROR) << "WindowsEventEngine:" << this
"WindowsEventEngine:%p uncleared TaskHandle at shutdown:%s", << " uncleared TaskHandle at shutdown:"
this, << HandleToString<EventEngine::TaskHandle>(handle);
HandleToString<EventEngine::TaskHandle>(handle).c_str());
} }
} }
// Allow a small grace period for timers to be run before shutting down. // Allow a small grace period for timers to be run before shutting down.

Loading…
Cancel
Save