[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log (#36701)

[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - 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.

Closes #36701

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36701 from tanvi-jagtap:test_core_gpr_log 1d8c69e9c6
PiperOrigin-RevId: 636850577
pull/36656/head^2
Tanvi Jagtap 9 months ago committed by Copybara-Service
parent 0ed095093c
commit 8881bde311
  1. 12
      test/core/compression/message_compress_test.cc
  2. 13
      test/core/event_engine/event_engine_test_utils.cc
  3. 9
      test/core/event_engine/forkable_test.cc
  4. 10
      test/core/event_engine/posix/event_poller_posix_test.cc
  5. 3
      test/core/event_engine/posix/posix_endpoint_test.cc
  6. 13
      test/core/event_engine/posix/posix_engine_listener_utils_test.cc
  7. 5
      test/core/event_engine/posix/posix_engine_test_utils.cc
  8. 4
      test/core/event_engine/posix/posix_event_engine_connect_test.cc
  9. 6
      test/core/event_engine/posix/timer_manager_test.cc
  10. 6
      test/core/event_engine/test_suite/tests/dns_test.cc
  11. 6
      test/core/event_engine/test_suite/tests/timer_test.cc
  12. 21
      test/core/event_engine/test_suite/tools/echo_client.cc
  13. 13
      test/core/event_engine/windows/create_sockpair.cc
  14. 5
      test/core/gprpp/examine_stack_test.cc
  15. 28
      test/core/http/httpcli_test.cc
  16. 14
      test/core/http/httpscli_test.cc
  17. 5
      test/core/iomgr/error_test.cc
  18. 4
      test/core/iomgr/fd_posix_test.cc
  19. 14
      test/core/iomgr/resolve_address_test.cc
  20. 32
      test/core/iomgr/tcp_posix_test.cc
  21. 7
      test/core/json/json_test.cc
  22. 8
      test/core/memory_usage/client.cc
  23. 9
      test/core/promise/sleep_test.cc
  24. 11
      test/core/resolver/binder_resolver_test.cc
  25. 27
      test/core/resolver/dns_resolver_cooldown_test.cc
  26. 11
      test/core/resolver/dns_resolver_test.cc
  27. 15
      test/core/resolver/sockaddr_resolver_test.cc
  28. 11
      test/core/resource_quota/memory_quota_stress_test.cc

@ -24,6 +24,7 @@
#include <memory> #include <memory>
#include "absl/log/log.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <grpc/compression.h> #include <grpc/compression.h>
@ -56,12 +57,11 @@ static void assert_passthrough(grpc_slice value,
const char* algorithm_name; const char* algorithm_name;
ASSERT_NE(grpc_compression_algorithm_name(algorithm, &algorithm_name), 0); ASSERT_NE(grpc_compression_algorithm_name(algorithm, &algorithm_name), 0);
gpr_log(GPR_INFO, LOG(INFO) << "assert_passthrough: value_length=" << GRPC_SLICE_LENGTH(value)
"assert_passthrough: value_length=%" PRIuPTR << " algorithm='" << algorithm_name << "' uncompressed_split='"
" algorithm='%s' uncompressed_split='%s' compressed_split='%s'", << grpc_slice_split_mode_name(uncompressed_split_mode)
GRPC_SLICE_LENGTH(value), algorithm_name, << "' compressed_split='"
grpc_slice_split_mode_name(uncompressed_split_mode), << grpc_slice_split_mode_name(compressed_split_mode) << "'";
grpc_slice_split_mode_name(compressed_split_mode));
grpc_slice_buffer_init(&input); grpc_slice_buffer_init(&input);
grpc_slice_buffer_init(&compressed_raw); grpc_slice_buffer_init(&compressed_raw);

@ -23,6 +23,7 @@
#include <utility> #include <utility>
#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/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
@ -34,7 +35,6 @@
#include <grpc/event_engine/slice.h> #include <grpc/event_engine/slice.h>
#include <grpc/event_engine/slice_buffer.h> #include <grpc/event_engine/slice_buffer.h>
#include <grpc/slice_buffer.h> #include <grpc/slice_buffer.h>
#include <grpc/support/log.h>
#include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h"
#include "src/core/lib/event_engine/tcp_socket_utils.h" #include "src/core/lib/event_engine/tcp_socket_utils.h"
@ -159,8 +159,8 @@ absl::Status SendValidatePayload(absl::string_view data,
// Check if data written == data read // Check if data written == data read
std::string data_read = ExtractSliceBufferIntoString(&read_store_buf); std::string data_read = ExtractSliceBufferIntoString(&read_store_buf);
if (data != data_read) { if (data != data_read) {
gpr_log(GPR_INFO, "Data written = %s", data.data()); LOG(INFO) << "Data written = " << data;
gpr_log(GPR_INFO, "Data read = %s", data_read.c_str()); LOG(INFO) << "Data read = " << data_read;
return absl::CancelledError("Data read != Data written"); return absl::CancelledError("Data read != Data written");
} }
return absl::OkStatus(); return absl::OkStatus();
@ -201,8 +201,8 @@ absl::Status ConnectionManager::BindAndStartListener(
for (auto& addr : addrs) { for (auto& addr : addrs) {
auto bind_status = listener->Bind(*URIToResolvedAddress(addr)); auto bind_status = listener->Bind(*URIToResolvedAddress(addr));
if (!bind_status.ok()) { if (!bind_status.ok()) {
gpr_log(GPR_ERROR, "Binding listener failed: %s", LOG(ERROR) << "Binding listener failed: "
bind_status.status().ToString().c_str()); << bind_status.status().ToString();
return bind_status.status(); return bind_status.status();
} }
} }
@ -230,8 +230,7 @@ ConnectionManager::CreateConnection(std::string target_addr,
event_engine->Connect( event_engine->Connect(
[this](absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> status) { [this](absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> status) {
if (!status.ok()) { if (!status.ok()) {
gpr_log(GPR_ERROR, "Connect failed: %s", LOG(ERROR) << "Connect failed: " << status.status().ToString();
status.status().ToString().c_str());
last_in_progress_connection_.SetClientEndpoint(nullptr); last_in_progress_connection_.SetClientEndpoint(nullptr);
} else { } else {
last_in_progress_connection_.SetClientEndpoint(std::move(*status)); last_in_progress_connection_.SetClientEndpoint(std::move(*status));

@ -25,11 +25,10 @@
#include <memory> #include <memory>
#include "absl/log/log.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <grpc/support/log.h>
#include "src/core/lib/config/config_vars.h" #include "src/core/lib/config/config_vars.h"
#include "src/core/lib/gprpp/no_destruct.h" #include "src/core/lib/gprpp/no_destruct.h"
@ -94,14 +93,14 @@ TEST_F(ForkableTest, BasicPthreadAtForkOperations) {
int child_pid = fork(); int child_pid = fork();
ASSERT_NE(child_pid, -1); ASSERT_NE(child_pid, -1);
if (child_pid == 0) { if (child_pid == 0) {
gpr_log(GPR_DEBUG, "I am child pid: %d", getpid()); VLOG(2) << "I am child pid: " << getpid();
forkable->CheckChild(); forkable->CheckChild();
exit(testing::Test::HasFailure()); exit(testing::Test::HasFailure());
} else { } else {
gpr_log(GPR_DEBUG, "I am parent pid: %d", getpid()); VLOG(2) << "I am parent pid: " << getpid();
forkable->CheckParent(); forkable->CheckParent();
int status; int status;
gpr_log(GPR_DEBUG, "Waiting for child pid: %d", child_pid); VLOG(2) << "Waiting for child pid: " << child_pid;
do { do {
// retry on EINTR, and fail otherwise // retry on EINTR, and fail otherwise
if (waitpid(child_pid, &status, 0) != -1) break; if (waitpid(child_pid, &status, 0) != -1) break;

@ -52,10 +52,10 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h> #include <unistd.h>
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include "src/core/lib/event_engine/common_closures.h" #include "src/core/lib/event_engine/common_closures.h"
@ -235,8 +235,8 @@ void ListenCb(server* sv, absl::Status status) {
listen_em_fd->NotifyOnRead(sv->listen_closure); listen_em_fd->NotifyOnRead(sv->listen_closure);
return; return;
} else if (fd < 0) { } else if (fd < 0) {
gpr_log(GPR_ERROR, "Failed to acceot a connection, returned error: %s", LOG(ERROR) << "Failed to acceot a connection, returned error: "
grpc_core::StrError(errno).c_str()); << grpc_core::StrError(errno);
} }
EXPECT_GE(fd, 0); EXPECT_GE(fd, 0);
EXPECT_LT(fd, FD_SETSIZE); EXPECT_LT(fd, FD_SETSIZE);
@ -349,7 +349,7 @@ void ClientStart(client* cl, int port) {
pfd.events = POLLOUT; pfd.events = POLLOUT;
pfd.revents = 0; pfd.revents = 0;
if (poll(&pfd, 1, -1) == -1) { if (poll(&pfd, 1, -1) == -1) {
gpr_log(GPR_ERROR, "poll() failed during connect; errno=%d", errno); LOG(ERROR) << "poll() failed during connect; errno=" << errno;
abort(); abort();
} }
} else { } else {
@ -389,7 +389,7 @@ class EventPollerTest : public ::testing::Test {
EXPECT_NE(engine_, nullptr); EXPECT_NE(engine_, nullptr);
scheduler_->ChangeCurrentEventEngine(engine_.get()); scheduler_->ChangeCurrentEventEngine(engine_.get());
if (g_event_poller != nullptr) { if (g_event_poller != nullptr) {
gpr_log(GPR_INFO, "Using poller: %s", g_event_poller->Name().c_str()); LOG(INFO) << "Using poller: " << g_event_poller->Name();
} }
} }

@ -24,6 +24,7 @@
#include <vector> #include <vector>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_split.h" #include "absl/strings/str_split.h"
@ -203,7 +204,7 @@ class PosixEndpointTest : public ::testing::TestWithParam<bool> {
EXPECT_NE(posix_ee_, nullptr); EXPECT_NE(posix_ee_, nullptr);
scheduler_->ChangeCurrentEventEngine(posix_ee_.get()); scheduler_->ChangeCurrentEventEngine(posix_ee_.get());
if (poller_ != nullptr) { if (poller_ != nullptr) {
gpr_log(GPR_INFO, "Using poller: %s", poller_->Name().c_str()); LOG(INFO) << "Using poller: " << poller_->Name();
} }
} }

@ -33,7 +33,7 @@
#include <ifaddrs.h> #include <ifaddrs.h>
#include <grpc/support/log.h> #include "absl/log/log.h"
#include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h"
#include "src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h" #include "src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h"
@ -108,9 +108,8 @@ TEST(PosixEngineListenerUtils, ListenerContainerAddAllLocalAddressesTest) {
struct ifaddrs* ifa_it; struct ifaddrs* ifa_it;
if (getifaddrs(&ifa) != 0 || ifa == nullptr) { if (getifaddrs(&ifa) != 0 || ifa == nullptr) {
// No ifaddresses available. // No ifaddresses available.
gpr_log(GPR_INFO, LOG(INFO) << "Skipping ListenerAddAllLocalAddressesTest because the "
"Skipping ListenerAddAllLocalAddressesTest because the machine " "machine does not have interfaces configured for listening.";
"does not have interfaces configured for listening.");
return; return;
} }
int num_ifaddrs = 0; int num_ifaddrs = 0;
@ -123,9 +122,9 @@ TEST(PosixEngineListenerUtils, ListenerContainerAddAllLocalAddressesTest) {
if (num_ifaddrs == 0 || !result.ok()) { if (num_ifaddrs == 0 || !result.ok()) {
// Its possible that the machine may not have any Ipv4/Ipv6 interfaces // Its possible that the machine may not have any Ipv4/Ipv6 interfaces
// configured for listening. In that case, dont fail test. // configured for listening. In that case, dont fail test.
gpr_log(GPR_INFO, LOG(INFO) << "Skipping ListenerAddAllLocalAddressesTest because the "
"Skipping ListenerAddAllLocalAddressesTest because the machine " "machine does not have Ipv6/Ipv6 interfaces configured for "
"does not have Ipv6/Ipv6 interfaces configured for listening."); "listening.";
return; return;
} }
// Some sockets have been created and bound to interfaces on the machiene. // Some sockets have been created and bound to interfaces on the machiene.

@ -20,10 +20,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/socket.h> #include <sys/socket.h>
#include "absl/log/log.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/crash.h"
namespace grpc_event_engine { namespace grpc_event_engine {
@ -53,7 +52,7 @@ int ConnectToServerOrDie(const ResolvedAddress& server_address) {
pfd.events = POLLOUT; pfd.events = POLLOUT;
pfd.revents = 0; pfd.revents = 0;
if (poll(&pfd, 1, -1) == -1) { if (poll(&pfd, 1, -1) == -1) {
gpr_log(GPR_ERROR, "poll() failed during connect; errno=%d", errno); LOG(ERROR) << "poll() failed during connect; errno=" << errno;
abort(); abort();
} }
} else { } else {

@ -27,6 +27,7 @@
#include <vector> #include <vector>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
@ -37,7 +38,6 @@
#include <grpc/event_engine/event_engine.h> #include <grpc/event_engine/event_engine.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h"
@ -121,7 +121,7 @@ std::vector<int> CreateConnectedSockets(
pfd.revents = 0; pfd.revents = 0;
int ret = poll(&pfd, 1, 1000); int ret = poll(&pfd, 1, 1000);
if (ret == -1) { if (ret == -1) {
gpr_log(GPR_ERROR, "poll() failed during connect; errno=%d", errno); LOG(ERROR) << "poll() failed during connect; errno=" << errno;
abort(); abort();
} else if (ret == 0) { } else if (ret == 0) {
// current connection attempt timed out. It indicates that the // current connection attempt timed out. It indicates that the

@ -19,12 +19,12 @@
#include <random> #include <random>
#include "absl/functional/any_invocable.h" #include "absl/functional/any_invocable.h"
#include "absl/log/log.h"
#include "absl/time/clock.h" #include "absl/time/clock.h"
#include "absl/time/time.h" #include "absl/time/time.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/event_engine/common_closures.h" #include "src/core/lib/event_engine/common_closures.h"
#include "src/core/lib/event_engine/posix_engine/timer.h" #include "src/core/lib/event_engine/posix_engine/timer.h"
@ -66,8 +66,8 @@ TEST(TimerManagerTest, StressTest) {
<< called.load(std::memory_order_relaxed) << "/" << kTimerCount << called.load(std::memory_order_relaxed) << "/" << kTimerCount
<< " callbacks executed"; << " callbacks executed";
} }
gpr_log(GPR_DEBUG, "Processed %d/%d callbacks", VLOG(2) << "Processed " << called.load(std::memory_order_relaxed) << "/"
called.load(std::memory_order_relaxed), kTimerCount); << kTimerCount << " callbacks";
absl::SleepFor(absl::Milliseconds(333)); absl::SleepFor(absl::Milliseconds(333));
} }
} }

@ -22,6 +22,7 @@
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -128,9 +129,8 @@ class EventEngineDNSTest : public EventEngineTest {
// an indication whether the test is running on RBE or not. Find a better way of // an indication whether the test is running on RBE or not. Find a better way of
// doing this. // doing this.
#ifndef GRPC_PORT_ISOLATED_RUNTIME #ifndef GRPC_PORT_ISOLATED_RUNTIME
gpr_log(GPR_ERROR, LOG(ERROR) << "You are invoking the test locally with Bazel, you may "
"You are invoking the test locally with Bazel, you may need to " "need to invoke Bazel with --enable_runfiles=yes.";
"invoke Bazel with --enable_runfiles=yes.");
#endif // GRPC_PORT_ISOLATED_RUNTIME #endif // GRPC_PORT_ISOLATED_RUNTIME
test_records_path = grpc::testing::NormalizeFilePath(test_records_path); test_records_path = grpc::testing::NormalizeFilePath(test_records_path);
dns_server_path = dns_server_path =

@ -26,13 +26,13 @@
#include "absl/functional/any_invocable.h" #include "absl/functional/any_invocable.h"
#include "absl/functional/bind_front.h" #include "absl/functional/bind_front.h"
#include "absl/functional/function_ref.h" #include "absl/functional/function_ref.h"
#include "absl/log/log.h"
#include "absl/time/clock.h" #include "absl/time/clock.h"
#include "absl/time/time.h" #include "absl/time/time.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <grpc/event_engine/event_engine.h> #include <grpc/event_engine/event_engine.h>
#include <grpc/support/log.h>
#include "src/core/lib/event_engine/time_util.h" #include "src/core/lib/event_engine/time_util.h"
#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/gprpp/sync.h"
@ -197,8 +197,8 @@ TEST_F(EventEngineTimerTest, StressTestTimersNotCalledBeforeScheduled) {
cv_.Wait(&mu_); cv_.Wait(&mu_);
} }
if (failed_call_count.load() != 0) { if (failed_call_count.load() != 0) {
gpr_log(GPR_DEBUG, "failed timer count: %d of %d", failed_call_count.load(), VLOG(2) << "failed timer count: " << failed_call_count.load() << " of "
thread_count * call_count); << (thread_count * call_count);
} }
ASSERT_EQ(0, failed_call_count.load()); ASSERT_EQ(0, failed_call_count.load());
} }

@ -39,6 +39,7 @@
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/flags/parse.h" #include "absl/flags/parse.h"
#include "absl/functional/any_invocable.h" #include "absl/functional/any_invocable.h"
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -46,7 +47,6 @@
#include <grpc/event_engine/event_engine.h> #include <grpc/event_engine/event_engine.h>
#include <grpc/event_engine/slice_buffer.h> #include <grpc/event_engine/slice_buffer.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args_preconditioning.h" #include "src/core/lib/channel/channel_args_preconditioning.h"
#include "src/core/lib/config/core_configuration.h" #include "src/core/lib/config/core_configuration.h"
@ -93,14 +93,12 @@ void ReceiveAndEchoMessage(EventEngine::Endpoint* endpoint, int message_id) {
endpoint->Read( endpoint->Read(
[&](absl::Status status) { [&](absl::Status status) {
if (!status.ok()) { if (!status.ok()) {
gpr_log(GPR_ERROR, "Error reading from endpoint: %s", LOG(ERROR) << "Error reading from endpoint: " << status;
status.ToString().c_str());
exit(1); exit(1);
} }
Slice received = buf.TakeFirst(); Slice received = buf.TakeFirst();
gpr_log(GPR_ERROR, "Received message %d: %.*s", message_id, LOG(ERROR) << "Received message " << message_id << ": "
static_cast<int>(received.as_string_view().length()), << received.as_string_view();
received.as_string_view().data());
read_done.Notify(); read_done.Notify();
}, },
&buf, nullptr); &buf, nullptr);
@ -124,8 +122,7 @@ void RunUntilInterrupted() {
engine->Connect( engine->Connect(
[&](absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> ep) { [&](absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> ep) {
if (!ep.ok()) { if (!ep.ok()) {
gpr_log(GPR_ERROR, "Error connecting: %s", LOG(ERROR) << "Error connecting: " << ep.status().ToString();
ep.status().ToString().c_str());
exit(1); exit(1);
} }
endpoint = std::move(*ep); endpoint = std::move(*ep);
@ -134,10 +131,10 @@ void RunUntilInterrupted() {
*addr, config, memory_quota->CreateMemoryAllocator("client"), 2h); *addr, config, memory_quota->CreateMemoryAllocator("client"), 2h);
connected.WaitForNotification(); connected.WaitForNotification();
CHECK_NE(endpoint.get(), nullptr); CHECK_NE(endpoint.get(), nullptr);
gpr_log(GPR_DEBUG, "peer addr: %s", VLOG(2) << "peer addr: "
ResolvedAddressToString(endpoint->GetPeerAddress())->c_str()); << ResolvedAddressToString(endpoint->GetPeerAddress());
gpr_log(GPR_DEBUG, "local addr: %s", VLOG(2) << "local addr: "
ResolvedAddressToString(endpoint->GetLocalAddress())->c_str()); << ResolvedAddressToString(endpoint->GetLocalAddress());
int message_id = 0; int message_id = 0;
while (true) { while (true) {
SendMessage(endpoint.get(), message_id++); SendMessage(endpoint.get(), message_id++);

@ -18,6 +18,7 @@
#include <ws2tcpip.h> #include <ws2tcpip.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 "src/core/lib/event_engine/windows/win_socket.h" #include "src/core/lib/event_engine/windows/win_socket.h"
@ -55,10 +56,8 @@ void CreateSockpair(SOCKET sockpair[2], DWORD flags) {
auto result = auto result =
WSAConnect(cli_sock, (sockaddr*)&addr, addr_len, NULL, NULL, NULL, NULL); WSAConnect(cli_sock, (sockaddr*)&addr, addr_len, NULL, NULL, NULL, NULL);
if (result != 0) { if (result != 0) {
gpr_log(GPR_DEBUG, "%s", VLOG(2)
GRPC_WSA_ERROR(WSAGetLastError(), "Failed in WSAConnect") << GRPC_WSA_ERROR(WSAGetLastError(), "Failed in WSAConnect").ToString();
.ToString()
.c_str());
abort(); abort();
} }
svr_sock = accept(lst_sock, (sockaddr*)&addr, &addr_len); svr_sock = accept(lst_sock, (sockaddr*)&addr, &addr_len);
@ -72,13 +71,11 @@ void CreateSockpair(SOCKET sockpair[2], DWORD flags) {
// logged status. WSAEINVAL is expected. // logged status. WSAEINVAL is expected.
auto status = PrepareSocket(cli_sock); auto status = PrepareSocket(cli_sock);
// if (!status.ok()) { // if (!status.ok()) {
// gpr_log(GPR_DEBUG, "Error preparing client socket: %s", // VLOG(2) << "Error preparing client socket: " << status.ToString();
// status.ToString().c_str());
// } // }
status = PrepareSocket(svr_sock); status = PrepareSocket(svr_sock);
// if (!status.ok()) { // if (!status.ok()) {
// gpr_log(GPR_DEBUG, "Error preparing server socket: %s", // VLOG(2) << "Error preparing server socket: " << status.ToString();
// status.ToString().c_str());
// } // }
sockpair[0] = svr_sock; sockpair[0] = svr_sock;

@ -20,11 +20,10 @@
#include "absl/debugging/stacktrace.h" #include "absl/debugging/stacktrace.h"
#include "absl/debugging/symbolize.h" #include "absl/debugging/symbolize.h"
#include "absl/log/log.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <grpc/support/log.h>
namespace { namespace {
std::string SimpleCurrentStackTraceProvider() { return "stacktrace"; } std::string SimpleCurrentStackTraceProvider() { return "stacktrace"; }
@ -67,7 +66,7 @@ TEST(ExamineStackTest, AbseilStackProvider) {
const absl::optional<std::string> stack_trace = const absl::optional<std::string> stack_trace =
grpc_core::GetCurrentStackTrace(); grpc_core::GetCurrentStackTrace();
EXPECT_NE(stack_trace, absl::nullopt); EXPECT_NE(stack_trace, absl::nullopt);
gpr_log(GPR_INFO, "stack_trace=%s", stack_trace->c_str()); LOG(INFO) << "stack_trace=" << *stack_trace;
#if !defined(NDEBUG) && !defined(GPR_MUSL_LIBC_COMPAT) #if !defined(NDEBUG) && !defined(GPR_MUSL_LIBC_COMPAT)
// Expect to see some gtest signature on the stack (this used to be // Expect to see some gtest signature on the stack (this used to be
// GetCurrentStackTrace, but some operating systems have trouble with the leaf // GetCurrentStackTrace, but some operating systems have trouble with the leaf

@ -30,6 +30,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/time/clock.h" #include "absl/time/clock.h"
@ -39,7 +40,6 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -163,8 +163,8 @@ void OnFinish(void* arg, grpc_error_handle error) {
"<html><head><title>Hello world!</title></head>" "<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>"; "<body><p>This is a test</p></body></html>";
grpc_http_response response = request_state->response; grpc_http_response response = request_state->response;
gpr_log(GPR_INFO, "response status=%d error=%s", response.status, LOG(INFO) << "response status=" << response.status
grpc_core::StatusToString(error).c_str()); << " error=" << grpc_core::StatusToString(error);
CHECK(error.ok()); CHECK(error.ok());
CHECK_EQ(response.status, 200); CHECK_EQ(response.status, 200);
CHECK(response.body_length == strlen(expect)); CHECK(response.body_length == strlen(expect));
@ -182,8 +182,8 @@ void OnFinishExpectFailure(void* arg, grpc_error_handle error) {
grpc_pollset_set_destroy(request_state->pollset_set_to_destroy_eagerly); grpc_pollset_set_destroy(request_state->pollset_set_to_destroy_eagerly);
} }
grpc_http_response response = request_state->response; grpc_http_response response = request_state->response;
gpr_log(GPR_INFO, "response status=%d error=%s", response.status, LOG(INFO) << "response status=" << response.status
grpc_core::StatusToString(error).c_str()); << " error=" << grpc_core::StatusToString(error);
CHECK(!error.ok()); CHECK(!error.ok());
request_state->test->RunAndKick( request_state->test->RunAndKick(
[request_state]() { request_state->done = true; }); [request_state]() { request_state->done = true; });
@ -194,7 +194,7 @@ TEST_F(HttpRequestTest, Get) {
grpc_http_request req; grpc_http_request req;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
std::string host = absl::StrFormat("localhost:%d", g_server_port); std::string host = absl::StrFormat("localhost:%d", g_server_port);
gpr_log(GPR_INFO, "requesting from %s", host.c_str()); LOG(INFO) << "requesting from " << host;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
auto uri = grpc_core::URI::Create("http", host, "/get", {} /* query params */, auto uri = grpc_core::URI::Create("http", host, "/get", {} /* query params */,
"" /* fragment */); "" /* fragment */);
@ -218,7 +218,7 @@ TEST_F(HttpRequestTest, Post) {
grpc_http_request req; grpc_http_request req;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
std::string host = absl::StrFormat("localhost:%d", g_server_port); std::string host = absl::StrFormat("localhost:%d", g_server_port);
gpr_log(GPR_INFO, "posting to %s", host.c_str()); LOG(INFO) << "posting to " << host;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.body = const_cast<char*>("hello"); req.body = const_cast<char*>("hello");
req.body_length = 5; req.body_length = 5;
@ -242,9 +242,8 @@ TEST_F(HttpRequestTest, Post) {
int g_fake_non_responsive_dns_server_port; int g_fake_non_responsive_dns_server_port;
void InjectNonResponsiveDNSServer(ares_channel* channel) { void InjectNonResponsiveDNSServer(ares_channel* channel) {
gpr_log(GPR_DEBUG, VLOG(2) << "Injecting broken nameserver list. Bad server address:|[::1]:"
"Injecting broken nameserver list. Bad server address:|[::1]:%d|.", << g_fake_non_responsive_dns_server_port << "|.";
g_fake_non_responsive_dns_server_port);
// Configure a non-responsive DNS server at the front of c-ares's nameserver // Configure a non-responsive DNS server at the front of c-ares's nameserver
// list. // list.
struct ares_addr_port_node dns_server_addrs[1]; struct ares_addr_port_node dns_server_addrs[1];
@ -492,10 +491,9 @@ TEST_F(HttpRequestTest, CallerPollentsAreNotReferencedAfterCallbackIsRan) {
} }
void CancelRequest(grpc_core::HttpRequest* req) { void CancelRequest(grpc_core::HttpRequest* req) {
gpr_log( LOG(INFO) << "test only HttpRequest::OnHandshakeDone intercept orphaning "
GPR_INFO, "request: "
"test only HttpRequest::OnHandshakeDone intercept orphaning request: %p", << req;
req);
req->Orphan(); req->Orphan();
} }
@ -511,7 +509,7 @@ TEST_F(HttpRequestTest,
grpc_http_request req; grpc_http_request req;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
std::string host = absl::StrFormat("localhost:%d", g_server_port); std::string host = absl::StrFormat("localhost:%d", g_server_port);
gpr_log(GPR_INFO, "requesting from %s", host.c_str()); LOG(INFO) << "requesting from " << host;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
auto uri = grpc_core::URI::Create("http", host, "/get", {} /* query params */, auto uri = grpc_core::URI::Create("http", host, "/get", {} /* query params */,
"" /* fragment */); "" /* fragment */);

@ -29,6 +29,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include "absl/time/clock.h" #include "absl/time/clock.h"
@ -37,7 +38,6 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -163,8 +163,8 @@ void OnFinish(void* arg, grpc_error_handle error) {
"<html><head><title>Hello world!</title></head>" "<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>"; "<body><p>This is a test</p></body></html>";
grpc_http_response response = request_state->response; grpc_http_response response = request_state->response;
gpr_log(GPR_INFO, "response status=%d error=%s", response.status, LOG(INFO) << "response status=" << response.status
grpc_core::StatusToString(error).c_str()); << " error=" << grpc_core::StatusToString(error);
CHECK(error.ok()); CHECK(error.ok());
CHECK_EQ(response.status, 200); CHECK_EQ(response.status, 200);
CHECK(response.body_length == strlen(expect)); CHECK(response.body_length == strlen(expect));
@ -176,8 +176,8 @@ void OnFinish(void* arg, grpc_error_handle error) {
void OnFinishExpectFailure(void* arg, grpc_error_handle error) { void OnFinishExpectFailure(void* arg, grpc_error_handle error) {
RequestState* request_state = static_cast<RequestState*>(arg); RequestState* request_state = static_cast<RequestState*>(arg);
grpc_http_response response = request_state->response; grpc_http_response response = request_state->response;
gpr_log(GPR_INFO, "response status=%d error=%s", response.status, LOG(INFO) << "response status=" << response.status
grpc_core::StatusToString(error).c_str()); << " error=" << grpc_core::StatusToString(error);
CHECK(!error.ok()); CHECK(!error.ok());
request_state->test->RunAndKick( request_state->test->RunAndKick(
[request_state]() { request_state->done = true; }); [request_state]() { request_state->done = true; });
@ -188,7 +188,7 @@ TEST_F(HttpsCliTest, Get) {
grpc_http_request req; grpc_http_request req;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
std::string host = absl::StrFormat("localhost:%d", g_server_port); std::string host = absl::StrFormat("localhost:%d", g_server_port);
gpr_log(GPR_INFO, "requesting from %s", host.c_str()); LOG(INFO) << "requesting from " << host;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
grpc_arg ssl_override_arg = grpc_channel_arg_string_create( grpc_arg ssl_override_arg = grpc_channel_arg_string_create(
const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
@ -214,7 +214,7 @@ TEST_F(HttpsCliTest, Post) {
grpc_http_request req; grpc_http_request req;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
std::string host = absl::StrFormat("localhost:%d", g_server_port); std::string host = absl::StrFormat("localhost:%d", g_server_port);
gpr_log(GPR_INFO, "posting to %s", host.c_str()); LOG(INFO) << "posting to " << host;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
req.body = const_cast<char*>("hello"); req.body = const_cast<char*>("hello");
req.body_length = 5; req.body_length = 5;

@ -22,9 +22,10 @@
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "absl/log/log.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/crash.h"
#include "test/core/test_util/test_config.h" #include "test/core/test_util/test_config.h"
@ -148,7 +149,7 @@ TEST(ErrorTest, PrintErrorString) {
error = grpc_error_set_int(error, grpc_core::StatusIntProperty::kSize, 666); error = grpc_error_set_int(error, grpc_core::StatusIntProperty::kSize, 666);
error = grpc_error_set_str(error, grpc_core::StatusStrProperty::kGrpcMessage, error = grpc_error_set_str(error, grpc_core::StatusStrProperty::kGrpcMessage,
"message"); "message");
// gpr_log(GPR_DEBUG, "%s", grpc_core::StatusToString(error).c_str()); // VLOG(2) << grpc_core::StatusToString(error);
} }
TEST(ErrorTest, PrintErrorStringReference) { TEST(ErrorTest, PrintErrorStringReference) {

@ -36,11 +36,11 @@
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#include "absl/log/log.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -396,7 +396,7 @@ static void test_grpc_fd(void) {
client_wait_and_shutdown(&cl); client_wait_and_shutdown(&cl);
server_wait_and_shutdown(&sv); server_wait_and_shutdown(&sv);
ASSERT_EQ(sv.read_bytes_total, cl.write_bytes_total); ASSERT_EQ(sv.read_bytes_total, cl.write_bytes_total);
gpr_log(GPR_INFO, "Total read bytes %" PRIdPTR, sv.read_bytes_total); LOG(INFO) << "Total read bytes " << sv.read_bytes_total;
} }
typedef struct fd_change_data { typedef struct fd_change_data {

@ -26,11 +26,11 @@
#include "absl/functional/bind_front.h" #include "absl/functional/bind_front.h"
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -102,8 +102,7 @@ class ResolveAddressTest : public ::testing::Test {
break; break;
} }
grpc_core::Duration time_left = deadline - grpc_core::Timestamp::Now(); grpc_core::Duration time_left = deadline - grpc_core::Timestamp::Now();
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64, done_, VLOG(2) << "done=" << done_ << ", time_left=" << time_left.millis();
time_left.millis());
ASSERT_GE(time_left, grpc_core::Duration::Zero()); ASSERT_GE(time_left, grpc_core::Duration::Zero());
grpc_pollset_worker* worker = nullptr; grpc_pollset_worker* worker = nullptr;
GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(pollset_, &worker, GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(pollset_, &worker,
@ -392,9 +391,8 @@ namespace {
int g_fake_non_responsive_dns_server_port; int g_fake_non_responsive_dns_server_port;
void InjectNonResponsiveDNSServer(ares_channel* channel) { void InjectNonResponsiveDNSServer(ares_channel* channel) {
gpr_log(GPR_DEBUG, VLOG(2) << "Injecting broken nameserver list. Bad server address:|[::1]:"
"Injecting broken nameserver list. Bad server address:|[::1]:%d|.", << g_fake_non_responsive_dns_server_port << "|.";
g_fake_non_responsive_dns_server_port);
// Configure a non-responsive DNS server at the front of c-ares's nameserver // Configure a non-responsive DNS server at the front of c-ares's nameserver
// list. // list.
struct ares_addr_port_node dns_server_addrs[1]; struct ares_addr_port_node dns_server_addrs[1];
@ -450,7 +448,7 @@ class PollsetSetWrapper {
grpc_core::ExecCtx::Get()->Flush(); grpc_core::ExecCtx::Get()->Flush();
grpc_pollset_destroy(ps_); grpc_pollset_destroy(ps_);
gpr_free(ps_); gpr_free(ps_);
gpr_log(GPR_DEBUG, "PollsetSetWrapper:%p deleted", this); VLOG(2) << "PollsetSetWrapper:" << this << " deleted";
} }
grpc_pollset_set* pollset_set() { return pss_; } grpc_pollset_set* pollset_set() { return pss_; }
@ -461,7 +459,7 @@ class PollsetSetWrapper {
grpc_pollset_init(ps_, &mu_); grpc_pollset_init(ps_, &mu_);
pss_ = grpc_pollset_set_create(); pss_ = grpc_pollset_set_create();
grpc_pollset_set_add_pollset(pss_, ps_); grpc_pollset_set_add_pollset(pss_, ps_);
gpr_log(GPR_DEBUG, "PollsetSetWrapper:%p created", this); VLOG(2) << "PollsetSetWrapper:" << this << " created";
} }
gpr_mu* mu_; gpr_mu* mu_;

@ -37,10 +37,10 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "src/core/lib/event_engine/channel_args_endpoint_config.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h"
@ -171,8 +171,8 @@ static void read_cb(void* user_data, grpc_error_handle error) {
read_bytes = count_slices(state->incoming.slices, state->incoming.count, read_bytes = count_slices(state->incoming.slices, state->incoming.count,
&current_data); &current_data);
state->read_bytes += read_bytes; state->read_bytes += read_bytes;
gpr_log(GPR_INFO, "Read %" PRIuPTR " bytes of %" PRIuPTR, read_bytes, LOG(INFO) << "Read " << read_bytes << " bytes of "
state->target_read_bytes); << state->target_read_bytes;
if (state->read_bytes >= state->target_read_bytes) { if (state->read_bytes >= state->target_read_bytes) {
CHECK(GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr))); CHECK(GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu); gpr_mu_unlock(g_mu);
@ -195,8 +195,8 @@ static void read_test(size_t num_bytes, size_t slice_size,
grpc_timeout_milliseconds_to_deadline(kDeadlineMillis)); grpc_timeout_milliseconds_to_deadline(kDeadlineMillis));
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_INFO, "Read test of size %" PRIuPTR ", slice size %" PRIuPTR, LOG(INFO) << "Read test of size " << num_bytes << ", slice size "
num_bytes, slice_size); << slice_size;
create_sockets(sv); create_sockets(sv);
@ -218,7 +218,7 @@ static void read_test(size_t num_bytes, size_t slice_size,
grpc_endpoint_add_to_pollset(ep, g_pollset); grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes); written_bytes = fill_socket_partial(sv[0], num_bytes);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes); LOG(INFO) << "Wrote " << written_bytes << " bytes";
state.ep = ep; state.ep = ep;
state.read_bytes = 0; state.read_bytes = 0;
@ -260,7 +260,7 @@ static void large_read_test(size_t slice_size, int min_progress_size) {
grpc_timeout_milliseconds_to_deadline(kDeadlineMillis)); grpc_timeout_milliseconds_to_deadline(kDeadlineMillis));
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_INFO, "Start large read test, slice size %" PRIuPTR, slice_size); LOG(INFO) << "Start large read test, slice size " << slice_size;
create_sockets(sv); create_sockets(sv);
@ -282,7 +282,7 @@ static void large_read_test(size_t slice_size, int min_progress_size) {
grpc_endpoint_add_to_pollset(ep, g_pollset); grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket(sv[0]); written_bytes = fill_socket(sv[0]);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes); LOG(INFO) << "Wrote " << written_bytes << " bytes";
state.ep = ep; state.ep = ep;
state.read_bytes = 0; state.read_bytes = 0;
@ -411,9 +411,8 @@ static void write_test(size_t num_bytes, size_t slice_size) {
grpc_timeout_milliseconds_to_deadline(kDeadlineMillis)); grpc_timeout_milliseconds_to_deadline(kDeadlineMillis));
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
gpr_log(GPR_INFO, LOG(INFO) << "Start write test with " << num_bytes << " bytes, slice size "
"Start write test with %" PRIuPTR " bytes, slice size %" PRIuPTR, << slice_size;
num_bytes, slice_size);
create_sockets(sv); create_sockets(sv);
@ -496,9 +495,8 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
GRPC_CLOSURE_INIT(&fd_released_cb, &on_fd_released, &rel_fd, GRPC_CLOSURE_INIT(&fd_released_cb, &on_fd_released, &rel_fd,
grpc_schedule_on_exec_ctx); grpc_schedule_on_exec_ctx);
gpr_log(GPR_INFO, LOG(INFO) << "Release fd read_test of size " << num_bytes << ", slice size "
"Release fd read_test of size %" PRIuPTR ", slice size %" PRIuPTR, << slice_size;
num_bytes, slice_size);
create_sockets(sv); create_sockets(sv);
@ -538,7 +536,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
grpc_endpoint_add_to_pollset(ep, g_pollset); grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes); written_bytes = fill_socket_partial(sv[0], num_bytes);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes); LOG(INFO) << "Wrote " << written_bytes << " bytes";
state.ep = ep; state.ep = ep;
state.read_bytes = 0; state.read_bytes = 0;
@ -555,8 +553,8 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
grpc_pollset_worker* worker = nullptr; grpc_pollset_worker* worker = nullptr;
CHECK(GRPC_LOG_IF_ERROR("pollset_work", CHECK(GRPC_LOG_IF_ERROR("pollset_work",
grpc_pollset_work(g_pollset, &worker, deadline))); grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_log(GPR_DEBUG, "wakeup: read=%" PRIdPTR " target=%" PRIdPTR, VLOG(2) << "wakeup: read=" << state.read_bytes
state.read_bytes, state.target_read_bytes); << " target=" << state.target_read_bytes;
gpr_mu_unlock(g_mu); gpr_mu_unlock(g_mu);
grpc_core::ExecCtx::Get()->Flush(); grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu); gpr_mu_lock(g_mu);

@ -22,6 +22,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
@ -29,8 +30,6 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <grpc/support/log.h>
#include "src/core/util/json/json_reader.h" #include "src/core/util/json/json_reader.h"
#include "src/core/util/json/json_writer.h" #include "src/core/util/json/json_writer.h"
#include "test/core/test_util/test_config.h" #include "test/core/test_util/test_config.h"
@ -79,7 +78,7 @@ void ValidateValue(const Json& actual, const Json& expected) {
void RunSuccessTest(const char* input, const Json& expected, void RunSuccessTest(const char* input, const Json& expected,
const char* expected_output) { const char* expected_output) {
gpr_log(GPR_INFO, "parsing string \"%s\" - should succeed", input); LOG(INFO) << "parsing string \"" << input << "\" - should succeed";
auto json = JsonParse(input); auto json = JsonParse(input);
ASSERT_TRUE(json.ok()) << json.status(); ASSERT_TRUE(json.ok()) << json.status();
ValidateValue(*json, expected); ValidateValue(*json, expected);
@ -200,7 +199,7 @@ TEST(Json, Keywords) {
} }
void RunParseFailureTest(const char* input) { void RunParseFailureTest(const char* input) {
gpr_log(GPR_INFO, "parsing string \"%s\" - should fail", input); LOG(INFO) << "parsing string \"" << input << "\" - should fail";
auto json = JsonParse(input); auto json = JsonParse(input);
EXPECT_FALSE(json.ok()) << "input: \"" << input << "\""; EXPECT_FALSE(json.ok()) << "input: \"" << input << "\"";
} }

@ -28,6 +28,7 @@
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/flags/parse.h" #include "absl/flags/parse.h"
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
@ -39,7 +40,6 @@
#include <grpc/impl/propagation_bits.h> #include <grpc/impl/propagation_bits.h>
#include <grpc/slice.h> #include <grpc/slice.h>
#include <grpc/status.h> #include <grpc/status.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
@ -161,9 +161,9 @@ static MemStats send_snapshot_request(int call_idx, grpc_slice call_type) {
(void*)nullptr, nullptr)); (void*)nullptr, nullptr));
grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
gpr_log(GPR_INFO, "Call %d status %d (%s)", call_idx, calls[call_idx].status, LOG(INFO) << "Call " << call_idx << " status " << calls[call_idx].status
std::string(grpc_core::StringViewFromSlice(calls[call_idx].details)) << " (" << grpc_core::StringViewFromSlice(calls[call_idx].details)
.c_str()); << ")";
CHECK_NE(response_payload_recv, nullptr); CHECK_NE(response_payload_recv, nullptr);
grpc_byte_buffer_reader reader; grpc_byte_buffer_reader reader;

@ -20,11 +20,11 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/log/log.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/gprpp/notification.h" #include "src/core/lib/gprpp/notification.h"
@ -156,7 +156,7 @@ TEST(Sleep, StressTest) {
std::vector<std::shared_ptr<Notification>> notifications; std::vector<std::shared_ptr<Notification>> notifications;
std::vector<ActivityPtr> activities; std::vector<ActivityPtr> activities;
auto engine = GetDefaultEventEngine(); auto engine = GetDefaultEventEngine();
gpr_log(GPR_INFO, "Starting %d sleeps for 1sec", kNumActivities); LOG(INFO) << "Starting " << kNumActivities << " sleeps for 1sec";
for (int i = 0; i < kNumActivities; i++) { for (int i = 0; i < kNumActivities; i++) {
auto notification = std::make_shared<Notification>(); auto notification = std::make_shared<Notification>();
auto activity = MakeActivity( auto activity = MakeActivity(
@ -167,9 +167,8 @@ TEST(Sleep, StressTest) {
notifications.push_back(std::move(notification)); notifications.push_back(std::move(notification));
activities.push_back(std::move(activity)); activities.push_back(std::move(activity));
} }
gpr_log(GPR_INFO, LOG(INFO) << "Waiting for the first " << (kNumActivities / 2)
"Waiting for the first %d sleeps, whilst cancelling the other half", << " sleeps, whilst cancelling the other half";
kNumActivities / 2);
for (size_t i = 0; i < kNumActivities / 2; i++) { for (size_t i = 0; i < kNumActivities / 2; i++) {
notifications[i]->WaitForNotification(); notifications[i]->WaitForNotification();
activities[i].reset(); activities[i].reset();

@ -43,8 +43,9 @@
#include <sys/un.h> #include <sys/un.h>
#endif // GPR_WINDOWS #endif // GPR_WINDOWS
#include "absl/log/log.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/resolver/resolver_registry.h" #include "src/core/resolver/resolver_registry.h"
@ -120,8 +121,8 @@ class BinderResolverTest : public ::testing::Test {
}; };
void TestSucceeds(const char* string, const std::string& expected_path) { void TestSucceeds(const char* string, const std::string& expected_path) {
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, VLOG(2) << "test: '" << string << "' should be valid for '"
std::string(factory_->scheme()).c_str()); << factory_->scheme();
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string); absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string);
ASSERT_TRUE(uri.ok()) << uri.status().ToString(); ASSERT_TRUE(uri.ok()) << uri.status().ToString();
@ -136,8 +137,8 @@ class BinderResolverTest : public ::testing::Test {
} }
void TestFails(const char* string) { void TestFails(const char* string) {
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, VLOG(2) << "test: '" << string << "' should be invalid for '"
std::string(factory_->scheme()).c_str()); << factory_->scheme();
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string); absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string);
ASSERT_TRUE(uri.ok()) << uri.status().ToString(); ASSERT_TRUE(uri.ok()) << uri.status().ToString();

@ -24,6 +24,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -34,7 +35,6 @@
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/atm.h> #include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -188,11 +188,10 @@ static grpc_ares_request* test_dns_lookup_ares(
static auto last_resolution_time = grpc_core::Timestamp::ProcessEpoch(); static auto last_resolution_time = grpc_core::Timestamp::ProcessEpoch();
auto now = auto now =
grpc_core::Timestamp::FromTimespecRoundUp(gpr_now(GPR_CLOCK_MONOTONIC)); grpc_core::Timestamp::FromTimespecRoundUp(gpr_now(GPR_CLOCK_MONOTONIC));
gpr_log(GPR_DEBUG, VLOG(2) << "last_resolution_time:"
"last_resolution_time:%" PRId64 " now:%" PRId64 << last_resolution_time.milliseconds_after_process_epoch()
" min_time_between:%d", << " now:" << now.milliseconds_after_process_epoch()
last_resolution_time.milliseconds_after_process_epoch(), << " min_time_between:" << kMinResolutionPeriodMs;
now.milliseconds_after_process_epoch(), kMinResolutionPeriodMs);
if (last_resolution_time != grpc_core::Timestamp::ProcessEpoch()) { if (last_resolution_time != grpc_core::Timestamp::ProcessEpoch()) {
EXPECT_GE(now - last_resolution_time, EXPECT_GE(now - last_resolution_time,
grpc_core::Duration::Milliseconds(kMinResolutionPeriodMs)); grpc_core::Duration::Milliseconds(kMinResolutionPeriodMs));
@ -253,7 +252,7 @@ static void poll_pollset_until_request_done(iomgr_args* args) {
break; break;
} }
grpc_core::Duration time_left = deadline - grpc_core::Timestamp::Now(); grpc_core::Duration time_left = deadline - grpc_core::Timestamp::Now();
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64, done, time_left.millis()); VLOG(2) << "done=" << done << ", time_left=" << time_left.millis();
ASSERT_GE(time_left, grpc_core::Duration::Zero()); ASSERT_GE(time_left, grpc_core::Duration::Zero());
grpc_pollset_worker* worker = nullptr; grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(args->mu); gpr_mu_lock(args->mu);
@ -311,7 +310,7 @@ static grpc_core::NoDestruct<grpc_core::Notification> g_all_callbacks_invoked;
// from "Now()". Thus the more rounds ran, the more highlighted the // from "Now()". Thus the more rounds ran, the more highlighted the
// difference is between absolute and relative times values. // difference is between absolute and relative times values.
static void on_fourth_resolution(OnResolutionCallbackArg* cb_arg) { static void on_fourth_resolution(OnResolutionCallbackArg* cb_arg) {
gpr_log(GPR_INFO, "4th: g_resolution_count: %d", g_resolution_count); LOG(INFO) << "4th: g_resolution_count: " << g_resolution_count;
ASSERT_EQ(g_resolution_count, 4); ASSERT_EQ(g_resolution_count, 4);
cb_arg->resolver.reset(); cb_arg->resolver.reset();
gpr_atm_rel_store(&g_iomgr_args.done_atm, 1); gpr_atm_rel_store(&g_iomgr_args.done_atm, 1);
@ -324,7 +323,7 @@ static void on_fourth_resolution(OnResolutionCallbackArg* cb_arg) {
} }
static void on_third_resolution(OnResolutionCallbackArg* cb_arg) { static void on_third_resolution(OnResolutionCallbackArg* cb_arg) {
gpr_log(GPR_INFO, "3rd: g_resolution_count: %d", g_resolution_count); LOG(INFO) << "3rd: g_resolution_count: " << g_resolution_count;
ASSERT_EQ(g_resolution_count, 3); ASSERT_EQ(g_resolution_count, 3);
cb_arg->result_handler->SetCallback(on_fourth_resolution, cb_arg); cb_arg->result_handler->SetCallback(on_fourth_resolution, cb_arg);
cb_arg->resolver->RequestReresolutionLocked(); cb_arg->resolver->RequestReresolutionLocked();
@ -335,7 +334,7 @@ static void on_third_resolution(OnResolutionCallbackArg* cb_arg) {
} }
static void on_second_resolution(OnResolutionCallbackArg* cb_arg) { static void on_second_resolution(OnResolutionCallbackArg* cb_arg) {
gpr_log(GPR_INFO, "2nd: g_resolution_count: %d", g_resolution_count); LOG(INFO) << "2nd: g_resolution_count: " << g_resolution_count;
// The resolution callback was not invoked until new data was // The resolution callback was not invoked until new data was
// available, which was delayed until after the cooldown period. // available, which was delayed until after the cooldown period.
ASSERT_EQ(g_resolution_count, 2); ASSERT_EQ(g_resolution_count, 2);
@ -348,7 +347,7 @@ static void on_second_resolution(OnResolutionCallbackArg* cb_arg) {
} }
static void on_first_resolution(OnResolutionCallbackArg* cb_arg) { static void on_first_resolution(OnResolutionCallbackArg* cb_arg) {
gpr_log(GPR_INFO, "1st: g_resolution_count: %d", g_resolution_count); LOG(INFO) << "1st: g_resolution_count: " << g_resolution_count;
// There's one initial system-level resolution and one invocation of a // There's one initial system-level resolution and one invocation of a
// notification callback (the current function). // notification callback (the current function).
ASSERT_EQ(g_resolution_count, 1); ASSERT_EQ(g_resolution_count, 1);
@ -369,10 +368,10 @@ static void start_test_under_work_serializer(void* arg) {
.LookupResolverFactory("dns"); .LookupResolverFactory("dns");
absl::StatusOr<grpc_core::URI> uri = absl::StatusOr<grpc_core::URI> uri =
grpc_core::URI::Parse(res_cb_arg->uri_str); grpc_core::URI::Parse(res_cb_arg->uri_str);
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", res_cb_arg->uri_str, VLOG(2) << "test: '" << res_cb_arg->uri_str << "' should be valid for '"
std::string(factory->scheme()).c_str()); << factory->scheme() << "'";
if (!uri.ok()) { if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str()); LOG(ERROR) << uri.status();
ASSERT_TRUE(uri.ok()); ASSERT_TRUE(uri.ok());
} }
grpc_core::ResolverArgs args; grpc_core::ResolverArgs args;

@ -20,13 +20,12 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/config/config_vars.h" #include "src/core/lib/config/config_vars.h"
#include "src/core/lib/config/core_configuration.h" #include "src/core/lib/config/core_configuration.h"
@ -50,8 +49,8 @@ class TestResultHandler : public grpc_core::Resolver::ResultHandler {
static void test_succeeds(grpc_core::ResolverFactory* factory, static void test_succeeds(grpc_core::ResolverFactory* factory,
const char* string) { const char* string) {
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, VLOG(2) << "test: '" << string << "' should be valid for '"
std::string(factory->scheme()).c_str()); << factory->scheme() << "'";
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string); absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string);
if (!uri.ok()) { if (!uri.ok()) {
@ -69,8 +68,8 @@ static void test_succeeds(grpc_core::ResolverFactory* factory,
static void test_fails(grpc_core::ResolverFactory* factory, static void test_fails(grpc_core::ResolverFactory* factory,
const char* string) { const char* string) {
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, VLOG(2) << "test: '" << string << "' should be invalid for '"
std::string(factory->scheme()).c_str()); << factory->scheme() << "'";
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string); absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string);
if (!uri.ok()) { if (!uri.ok()) {

@ -20,12 +20,11 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <grpc/support/log.h>
#include "src/core/lib/config/core_configuration.h" #include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/orphanable.h"
@ -47,12 +46,12 @@ class ResultHandler : public grpc_core::Resolver::ResultHandler {
static void test_succeeds(grpc_core::ResolverFactory* factory, static void test_succeeds(grpc_core::ResolverFactory* factory,
const char* string) { const char* string) {
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, VLOG(2) << "test: '" << string << "' should be valid for '"
std::string(factory->scheme()).c_str()); << factory->scheme() << "'";
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string); absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string);
if (!uri.ok()) { if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str()); LOG(ERROR) << uri.status().ToString();
ASSERT_TRUE(uri.ok()); ASSERT_TRUE(uri.ok());
} }
grpc_core::ResolverArgs args; grpc_core::ResolverArgs args;
@ -70,12 +69,12 @@ static void test_succeeds(grpc_core::ResolverFactory* factory,
static void test_fails(grpc_core::ResolverFactory* factory, static void test_fails(grpc_core::ResolverFactory* factory,
const char* string) { const char* string) {
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, VLOG(2) << "test: '" << string << "' should be invalid for '"
std::string(factory->scheme()).c_str()); << factory->scheme() << "'";
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string); absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(string);
if (!uri.ok()) { if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str()); LOG(ERROR) << uri.status().ToString();
ASSERT_TRUE(uri.ok()); ASSERT_TRUE(uri.ok());
} }
grpc_core::ResolverArgs args; grpc_core::ResolverArgs args;

@ -25,13 +25,13 @@
#include <vector> #include <vector>
#include "absl/base/thread_annotations.h" #include "absl/base/thread_annotations.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <grpc/event_engine/memory_allocator.h> #include <grpc/event_engine/memory_allocator.h>
#include <grpc/event_engine/memory_request.h> #include <grpc/event_engine/memory_request.h>
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/sync.h" #include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/exec_ctx.h"
@ -229,11 +229,10 @@ class StressTest {
TEST(MemoryQuotaStressTest, MainTest) { TEST(MemoryQuotaStressTest, MainTest) {
if (sizeof(void*) != 8) { if (sizeof(void*) != 8) {
gpr_log( LOG(ERROR) << "This test assumes 64-bit processors in the values it uses "
GPR_ERROR, "for sizes. Since this test is mostly aimed at TSAN "
"This test assumes 64-bit processors in the values it uses for sizes. " "coverage, and that's mostly platform independent, we simply "
"Since this test is mostly aimed at TSAN coverage, and that's mostly " "skip this test in 32-bit builds.";
"platform independent, we simply skip this test in 32-bit builds.");
GTEST_SKIP(); GTEST_SKIP();
} }
grpc_core::StressTest(16, 20).Run(8); grpc_core::StressTest(16, 20).Run(8);

Loading…
Cancel
Save