diff --git a/src/objective-c/tests/CFStreamTests/CFStreamClientTests.mm b/src/objective-c/tests/CFStreamTests/CFStreamClientTests.mm index 140d8609314..c78c090cb0a 100644 --- a/src/objective-c/tests/CFStreamTests/CFStreamClientTests.mm +++ b/src/objective-c/tests/CFStreamTests/CFStreamClientTests.mm @@ -85,7 +85,7 @@ static void must_fail(void* arg, grpc_error_handle error) { grpc_closure done; grpc_core::ExecCtx exec_ctx; - gpr_log(GPR_DEBUG, "test_succeeds"); + VLOG(2) << "test_succeeds"; auto resolved_addr = grpc_core::StringToSockaddr("127.0.0.1:0"); CHECK(resolved_addr.ok()); @@ -142,7 +142,7 @@ static void must_fail(void* arg, grpc_error_handle error) { grpc_closure done; int svr_fd; - gpr_log(GPR_DEBUG, "test_fails"); + VLOG(2) << "test_fails"; auto resolved_addr = grpc_core::StringToSockaddr("127.0.0.1:0"); CHECK(resolved_addr.ok()); diff --git a/src/objective-c/tests/CFStreamTests/CFStreamEndpointTests.mm b/src/objective-c/tests/CFStreamTests/CFStreamEndpointTests.mm index 97508b83cb8..b516040cdeb 100644 --- a/src/objective-c/tests/CFStreamTests/CFStreamEndpointTests.mm +++ b/src/objective-c/tests/CFStreamTests/CFStreamEndpointTests.mm @@ -112,7 +112,7 @@ static bool compare_slice_buffer_with_buffer(grpc_slice_buffer *slices, const ch std::promise connected_promise; grpc_closure done; - gpr_log(GPR_DEBUG, "test_succeeds"); + VLOG(2) << "test_succeeds"; auto resolved_addr = grpc_core::StringToSockaddr("127.0.0.1:0"); struct sockaddr_in *addr = reinterpret_cast(resolved_addr->addr); diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm b/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm index 77adb057d24..0cbd7e997b8 100644 --- a/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm @@ -84,7 +84,7 @@ static void must_fail(void* arg, grpc_error_handle error) { grpc_closure done; grpc_core::ExecCtx exec_ctx; - gpr_log(GPR_DEBUG, "test_succeeds"); + VLOG(2) << "test_succeeds"; auto resolved_addr = grpc_core::StringToSockaddr("127.0.0.1:0"); CHECK(resolved_addr.ok()); @@ -141,7 +141,7 @@ static void must_fail(void* arg, grpc_error_handle error) { grpc_closure done; int svr_fd; - gpr_log(GPR_DEBUG, "test_fails"); + VLOG(2) << "test_fails"; auto resolved_addr = grpc_core::StringToSockaddr("127.0.0.1:0"); CHECK(resolved_addr.ok()); diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm b/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm index c5fe36482c7..5ba1c11ed3b 100644 --- a/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm @@ -111,7 +111,7 @@ static bool compare_slice_buffer_with_buffer(grpc_slice_buffer *slices, const ch std::promise connected_promise; grpc_closure done; - gpr_log(GPR_DEBUG, "test_succeeds"); + VLOG(2) << "test_succeeds"; auto resolved_addr = grpc_core::StringToSockaddr("127.0.0.1:0"); struct sockaddr_in *addr = reinterpret_cast(resolved_addr->addr); diff --git a/test/cpp/common/time_jump_test.cc b/test/cpp/common/time_jump_test.cc index 8e7f4f7649c..ef7adb4ad02 100644 --- a/test/cpp/common/time_jump_test.cc +++ b/test/cpp/common/time_jump_test.cc @@ -26,10 +26,10 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/time/time.h" #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/sync.h" @@ -106,7 +106,7 @@ TEST_P(TimeJumpTest, TimerRunning) { gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(kWaitTimeMs)); // We expect 1 wakeup/sec when there are not timer expiries int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); - gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); + VLOG(2) << "wakeups: " << wakeups; CHECK_LE(wakeups, 3); grpc_timer_cancel(&timer); } @@ -126,8 +126,8 @@ TEST_P(TimeJumpTest, TimedWait) { bool timedout = cond.WaitWithTimeout(&mu, absl::Milliseconds(kWaitTimeMs)); gpr_timespec after = gpr_now(GPR_CLOCK_MONOTONIC); int32_t elapsed_ms = gpr_time_to_millis(gpr_time_sub(after, before)); - gpr_log(GPR_DEBUG, "After wait, timedout = %d elapsed_ms = %d", timedout, - elapsed_ms); + VLOG(2) << "After wait, timedout = " << timedout + << " elapsed_ms = " << elapsed_ms; CHECK_EQ(timedout, 1); CHECK(1 == gpr_time_similar(gpr_time_sub(after, before), gpr_time_from_millis(kWaitTimeMs, GPR_TIMESPAN), @@ -137,7 +137,7 @@ TEST_P(TimeJumpTest, TimedWait) { } // We expect 1 wakeup/sec when there are not timer expiries int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); - gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); + VLOG(2) << "wakeups: " << wakeups; CHECK_LE(wakeups, 3); } diff --git a/test/cpp/common/timer_test.cc b/test/cpp/common/timer_test.cc index edf5b64055e..3cc129cefb2 100644 --- a/test/cpp/common/timer_test.cc +++ b/test/cpp/common/timer_test.cc @@ -21,9 +21,9 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/time.h" @@ -105,7 +105,7 @@ TEST_F(TimerTest, OneTimerExpires) { // Actual number of wakeups is more due to bug // https://github.com/grpc/grpc/issues/19947 int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); - gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); + VLOG(2) << "wakeups: " << wakeups; } TEST_F(TimerTest, MultipleTimersExpire) { @@ -135,7 +135,7 @@ TEST_F(TimerTest, MultipleTimersExpire) { // wakeups. Actual number of wakeups is more due to bug // https://github.com/grpc/grpc/issues/19947 int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); - gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); + VLOG(2) << "wakeups: " << wakeups; } TEST_F(TimerTest, CancelSomeTimers) { @@ -177,7 +177,7 @@ TEST_F(TimerTest, CancelSomeTimers) { // Actual number of wakeups is more due to bug // https://github.com/grpc/grpc/issues/19947 int64_t wakeups = grpc_timer_manager_get_wakeups_testonly(); - gpr_log(GPR_DEBUG, "wakeups: %" PRId64 "", wakeups); + VLOG(2) << "wakeups: " << wakeups; } // Enable the following test after diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index e2ae51aefb8..b4f7657ecfc 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -21,13 +21,13 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include #include -#include #include #include #include @@ -276,7 +276,7 @@ std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) { void TestScenario::Log() const { std::ostringstream out; out << *this; - gpr_log(GPR_DEBUG, "%s", out.str().c_str()); + VLOG(2) << out.str(); } class HealthCheck : public health::v1::Health::Service {}; diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index b811bfde48f..88ce497a590 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -26,6 +26,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/memory/memory.h" #include @@ -81,7 +82,7 @@ std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) { void TestScenario::Log() const { std::ostringstream out; out << *this; - gpr_log(GPR_DEBUG, "%s", out.str().c_str()); + VLOG(2) << out.str(); } class ClientCallbackEnd2endTest @@ -669,7 +670,7 @@ class WriteClient : public grpc::ClientWriteReactor { } } void OnDone(const Status& s) override { - gpr_log(GPR_INFO, "Sent %d messages", num_msgs_sent_); + LOG(INFO) << "Sent " << num_msgs_sent_ << " messages"; int num_to_send = (client_cancel_.cancel) ? std::min(num_msgs_to_send_, client_cancel_.ops_before_cancel) @@ -958,7 +959,7 @@ class ReadClient : public grpc::ClientReadReactor { } } void OnDone(const Status& s) override { - gpr_log(GPR_INFO, "Read %d messages", reads_complete_); + LOG(INFO) << "Read " << reads_complete_ << " messages"; switch (server_try_cancel_) { case DO_NOT_CANCEL: if (!client_cancel_.cancel || client_cancel_.ops_before_cancel > @@ -1119,8 +1120,8 @@ class BidiClient : public grpc::ClientBidiReactor { MaybeWrite(); } void OnDone(const Status& s) override { - gpr_log(GPR_INFO, "Sent %d messages", writes_complete_); - gpr_log(GPR_INFO, "Read %d messages", reads_complete_); + LOG(INFO) << "Sent " << writes_complete_ << " messages"; + LOG(INFO) << "Read " << reads_complete_ << " messages"; switch (server_try_cancel_) { case DO_NOT_CANCEL: if (!client_cancel_.cancel || diff --git a/test/cpp/end2end/client_crash_test_server.cc b/test/cpp/end2end/client_crash_test_server.cc index 1d518a43ff4..441e8e3dbcb 100644 --- a/test/cpp/end2end/client_crash_test_server.cc +++ b/test/cpp/end2end/client_crash_test_server.cc @@ -21,8 +21,8 @@ #include #include "absl/flags/flag.h" +#include "absl/log/log.h" -#include #include #include #include @@ -46,7 +46,7 @@ class ServiceImpl final : public grpc::testing::EchoTestService::Service { EchoRequest request; EchoResponse response; while (stream->Read(&request)) { - gpr_log(GPR_INFO, "recv msg %s", request.message().c_str()); + LOG(INFO) << "recv msg " << request.message(); response.set_message(request.message()); stream->Write(response); } diff --git a/test/cpp/end2end/context_allocator_end2end_test.cc b/test/cpp/end2end/context_allocator_end2end_test.cc index 78f984b6339..6b9b7a355e7 100644 --- a/test/cpp/end2end/context_allocator_end2end_test.cc +++ b/test/cpp/end2end/context_allocator_end2end_test.cc @@ -28,8 +28,8 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" -#include #include #include #include @@ -70,7 +70,7 @@ std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) { void TestScenario::Log() const { std::ostringstream out; out << *this; - gpr_log(GPR_INFO, "%s", out.str().c_str()); + LOG(INFO) << out.str(); } class ContextAllocatorEnd2endTestBase diff --git a/test/cpp/end2end/crl_provider_test.cc b/test/cpp/end2end/crl_provider_test.cc index b88d696d032..c8e332b0a12 100644 --- a/test/cpp/end2end/crl_provider_test.cc +++ b/test/cpp/end2end/crl_provider_test.cc @@ -22,6 +22,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" @@ -29,7 +30,6 @@ #include #include -#include #include #include #include @@ -147,8 +147,8 @@ void DoRpc(const std::string& server_addr, if (expect_success) { EXPECT_TRUE(result.ok()); if (!result.ok()) { - gpr_log(GPR_ERROR, "%s, %s", result.error_message().c_str(), - result.error_details().c_str()); + LOG(ERROR) << result.error_message().c_str() << ", " + << result.error_details().c_str(); } EXPECT_EQ(response.message(), kMessage); } else { diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc index bb8b07da8ef..20b920f6276 100644 --- a/test/cpp/end2end/hybrid_end2end_test.cc +++ b/test/cpp/end2end/hybrid_end2end_test.cc @@ -22,6 +22,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include #include @@ -213,7 +214,7 @@ void HandleGenericCall(AsyncGenericService* service, "/grpc.testing.EchoTestService/RequestStream") { HandleGenericRequestStream(&stream, cq); } else { // other methods not handled yet. - gpr_log(GPR_ERROR, "method: %s", srv_ctx.method().c_str()); + LOG(ERROR) << "method: " << srv_ctx.method(); CHECK(0); } } @@ -572,7 +573,7 @@ class StreamedUnaryDupPkg EchoResponse resp; uint32_t next_msg_sz; stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Streamed Unary Next Message Size is %u", next_msg_sz); + LOG(INFO) << "Streamed Unary Next Message Size is " << next_msg_sz; CHECK(stream->Read(&req)); resp.set_message(req.message() + "_dup"); CHECK(stream->Write(resp)); @@ -610,7 +611,7 @@ class FullyStreamedUnaryDupPkg EchoResponse resp; uint32_t next_msg_sz; stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Streamed Unary Next Message Size is %u", next_msg_sz); + LOG(INFO) << "Streamed Unary Next Message Size is " << next_msg_sz; CHECK(stream->Read(&req)); resp.set_message(req.message() + "_dup"); CHECK(stream->Write(resp)); @@ -649,7 +650,7 @@ class SplitResponseStreamDupPkg EchoResponse resp; uint32_t next_msg_sz; stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Split Streamed Next Message Size is %u", next_msg_sz); + LOG(INFO) << "Split Streamed Next Message Size is " << next_msg_sz; CHECK(stream->Read(&req)); for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { resp.set_message(req.message() + std::to_string(i) + "_dup"); @@ -689,7 +690,7 @@ class FullySplitStreamedDupPkg EchoResponse resp; uint32_t next_msg_sz; stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Split Streamed Next Message Size is %u", next_msg_sz); + LOG(INFO) << "Split Streamed Next Message Size is " << next_msg_sz; CHECK(stream->Read(&req)); for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { resp.set_message(req.message() + std::to_string(i) + "_dup"); @@ -728,7 +729,7 @@ class FullyStreamedDupPkg : public duplicate::EchoTestService::StreamedService { EchoResponse resp; uint32_t next_msg_sz; stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Streamed Unary Next Message Size is %u", next_msg_sz); + LOG(INFO) << "Streamed Unary Next Message Size is " << next_msg_sz; CHECK(stream->Read(&req)); resp.set_message(req.message() + "_dup"); CHECK(stream->Write(resp)); @@ -741,7 +742,7 @@ class FullyStreamedDupPkg : public duplicate::EchoTestService::StreamedService { EchoResponse resp; uint32_t next_msg_sz; stream->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "Split Streamed Next Message Size is %u", next_msg_sz); + LOG(INFO) << "Split Streamed Next Message Size is " << next_msg_sz; CHECK(stream->Read(&req)); for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { resp.set_message(req.message() + std::to_string(i) + "_dup"); @@ -812,8 +813,8 @@ TEST_P(HybridEnd2endTest, CallbackGenericEcho) { ServerGenericBidiReactor* CreateReactor( GenericCallbackServerContext* context) override { EXPECT_EQ(context->method(), "/grpc.testing.EchoTestService/Echo"); - gpr_log(GPR_DEBUG, "Constructor of generic service %d", - static_cast(context->deadline().time_since_epoch().count())); + VLOG(2) << "Constructor of generic service " + << context->deadline().time_since_epoch().count(); class Reactor : public ServerGenericBidiReactor { public: diff --git a/test/cpp/end2end/message_allocator_end2end_test.cc b/test/cpp/end2end/message_allocator_end2end_test.cc index 02ec6cd3fe5..5546f5685f5 100644 --- a/test/cpp/end2end/message_allocator_end2end_test.cc +++ b/test/cpp/end2end/message_allocator_end2end_test.cc @@ -29,8 +29,8 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" -#include #include #include #include @@ -99,7 +99,7 @@ std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) { void TestScenario::Log() const { std::ostringstream out; out << *this; - gpr_log(GPR_INFO, "%s", out.str().c_str()); + LOG(INFO) << out.str(); } class MessageAllocatorEnd2endTestBase diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc index 512fe8dcbf1..f561ec70a20 100644 --- a/test/cpp/end2end/mock_test.cc +++ b/test/cpp/end2end/mock_test.cc @@ -22,10 +22,10 @@ #include #include +#include "absl/log/log.h" #include "absl/types/optional.h" #include -#include #include #include #include @@ -253,7 +253,7 @@ class TestServiceImpl : public EchoTestService::Service { EchoRequest request; std::string resp; while (reader->Read(&request)) { - gpr_log(GPR_INFO, "recv msg %s", request.message().c_str()); + LOG(INFO) << "recv msg " << request.message(); resp.append(request.message()); } response->set_message(resp); @@ -277,7 +277,7 @@ class TestServiceImpl : public EchoTestService::Service { EchoRequest request; EchoResponse response; while (stream->Read(&request)) { - gpr_log(GPR_INFO, "recv msg %s", request.message().c_str()); + LOG(INFO) << "recv msg " << request.message(); response.set_message(request.message()); stream->Write(response); } diff --git a/test/cpp/end2end/port_sharing_end2end_test.cc b/test/cpp/end2end/port_sharing_end2end_test.cc index cf6f6f9fdef..05c03c79a93 100644 --- a/test/cpp/end2end/port_sharing_end2end_test.cc +++ b/test/cpp/end2end/port_sharing_end2end_test.cc @@ -22,10 +22,10 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include #include -#include #include #include #include @@ -85,7 +85,7 @@ std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) { void TestScenario::Log() const { std::ostringstream out; out << *this; - gpr_log(GPR_ERROR, "%s", out.str().c_str()); + LOG(ERROR) << out.str(); } // Set up a test tcp server which is in charge of accepting connections and @@ -115,7 +115,7 @@ class TestTcpServer { void Start() { test_tcp_server_start(&tcp_server_, port_); - gpr_log(GPR_INFO, "Test TCP server started at %s", address_.c_str()); + LOG(INFO) << "Test TCP server started at " << address_; } const std::string& address() { return address_; } @@ -160,7 +160,7 @@ class TestTcpServer { void OnConnect(grpc_endpoint* tcp, grpc_pollset* /*accepting_pollset*/, grpc_tcp_server_acceptor* acceptor) { std::string peer(grpc_endpoint_get_peer(tcp)); - gpr_log(GPR_INFO, "Got incoming connection! from %s", peer.c_str()); + LOG(INFO) << "Got incoming connection! from " << peer; EXPECT_FALSE(acceptor->external_connection); listener_fd_ = grpc_tcp_server_port_fd( acceptor->from_server, acceptor->port_index, acceptor->fd_index); @@ -182,8 +182,9 @@ class TestTcpServer { Slice data(buf, read_bytes); p.read_buffer = ByteBuffer(&data, 1); } - gpr_log(GPR_INFO, "Handing off fd %d with data size %d from listener fd %d", - fd_, static_cast(p.read_buffer.Length()), listener_fd_); + LOG(INFO) << "Handing off fd " << fd_ << " with data size " + << static_cast(p.read_buffer.Length()) + << " from listener fd " << listener_fd_; connection_acceptor_->HandleNewConnection(&p); } @@ -224,8 +225,7 @@ class PortSharingEnd2endTest : public ::testing::TestWithParam { auto creds = GetCredentialsProvider()->GetServerCredentials( GetParam().credentials_type); builder.AddListeningPort(server_address_.str(), creds); - gpr_log(GPR_INFO, "gRPC server listening on %s", - server_address_.str().c_str()); + LOG(INFO) << "gRPC server listening on " << server_address_.str(); } auto server_creds = GetCredentialsProvider()->GetServerCredentials( GetParam().credentials_type); diff --git a/test/cpp/end2end/rls_end2end_test.cc b/test/cpp/end2end/rls_end2end_test.cc index ca6616fe6b7..618b9213c01 100644 --- a/test/cpp/end2end/rls_end2end_test.cc +++ b/test/cpp/end2end/rls_end2end_test.cc @@ -29,6 +29,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "absl/types/optional.h" @@ -417,7 +418,7 @@ class RlsEnd2endTest : public ::testing::Test { service_(std::forward(args)...) {} void Start() { - gpr_log(GPR_INFO, "starting %s server on port %d", type_.c_str(), port_); + LOG(INFO) << "starting " << type_ << " server on port " << port_; CHECK(!running_); running_ = true; service_.Start(); @@ -429,7 +430,7 @@ class RlsEnd2endTest : public ::testing::Test { thread_ = std::make_unique( std::bind(&ServerThread::Serve, this, &mu, &cond)); cond.Wait(&mu); - gpr_log(GPR_INFO, "%s server startup complete", type_.c_str()); + LOG(INFO) << type_ << " server startup complete"; } void Serve(grpc::internal::Mutex* mu, grpc::internal::CondVar* cond) { @@ -448,11 +449,11 @@ class RlsEnd2endTest : public ::testing::Test { void Shutdown() { if (!running_) return; - gpr_log(GPR_INFO, "%s about to shutdown", type_.c_str()); + LOG(INFO) << type_ << " about to shutdown"; service_.Shutdown(); server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0)); thread_->join(); - gpr_log(GPR_INFO, "%s shutdown completed", type_.c_str()); + LOG(INFO) << type_ << " shutdown completed"; running_ = false; } diff --git a/test/cpp/end2end/server_crash_test.cc b/test/cpp/end2end/server_crash_test.cc index a2cbe5b836a..6973f054dcb 100644 --- a/test/cpp/end2end/server_crash_test.cc +++ b/test/cpp/end2end/server_crash_test.cc @@ -19,10 +19,10 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/memory/memory.h" #include -#include #include #include #include @@ -59,7 +59,7 @@ class ServiceImpl final : public grpc::testing::EchoTestService::Service { EchoRequest request; EchoResponse response; while (stream->Read(&request)) { - gpr_log(GPR_INFO, "recv msg %s", request.message().c_str()); + LOG(INFO) << "recv msg " << request.message(); response.set_message(request.message()); stream->Write(response); gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), diff --git a/test/cpp/end2end/server_crash_test_client.cc b/test/cpp/end2end/server_crash_test_client.cc index 29f4f1bddb0..4d2e266f025 100644 --- a/test/cpp/end2end/server_crash_test_client.cc +++ b/test/cpp/end2end/server_crash_test_client.cc @@ -23,8 +23,8 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" -#include #include #include #include @@ -67,8 +67,7 @@ int main(int argc, char** argv) { CHECK(stream->Read(&response)); } } else { - gpr_log(GPR_ERROR, "invalid test mode '%s'", - absl::GetFlag(FLAGS_mode).c_str()); + LOG(ERROR) << "invalid test mode '" << absl::GetFlag(FLAGS_mode) << "'"; return 1; } } diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc index 56cc55e72da..baae51856b5 100644 --- a/test/cpp/end2end/shutdown_test.cc +++ b/test/cpp/end2end/shutdown_test.cc @@ -21,9 +21,9 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include -#include #include #include #include @@ -132,7 +132,7 @@ std::vector GetAllCredentialsTypeList() { for (const string& type : credentials_types) { credentials_type_list.append(" " + type); } - gpr_log(GPR_INFO, "%s", credentials_type_list.c_str()); + LOG(INFO) << credentials_type_list; return credentials_types; } diff --git a/test/cpp/end2end/ssl_credentials_test.cc b/test/cpp/end2end/ssl_credentials_test.cc index de505e4b67e..325dc79068d 100644 --- a/test/cpp/end2end/ssl_credentials_test.cc +++ b/test/cpp/end2end/ssl_credentials_test.cc @@ -20,6 +20,7 @@ #include #include +#include "absl/log/log.h" #include "absl/synchronization/notification.h" #include @@ -103,8 +104,7 @@ void DoRpc(const std::string& server_addr, grpc::Status result = stub->Echo(&context, request, &response); EXPECT_TRUE(result.ok()); if (!result.ok()) { - gpr_log(GPR_ERROR, "%s, %s", result.error_message().c_str(), - result.error_details().c_str()); + LOG(ERROR) << result.error_message() << ", " << result.error_details(); } EXPECT_EQ(response.message(), kMessage); std::shared_ptr auth_context = context.auth_context(); diff --git a/test/cpp/end2end/streaming_throughput_test.cc b/test/cpp/end2end/streaming_throughput_test.cc index 33fd20ae0a3..a7a3511d157 100644 --- a/test/cpp/end2end/streaming_throughput_test.cc +++ b/test/cpp/end2end/streaming_throughput_test.cc @@ -23,9 +23,10 @@ #include +#include "absl/log/log.h" + #include #include -#include #include #include #include @@ -177,7 +178,7 @@ TEST_F(End2endTest, StreamingThroughput) { request.set_message(kLargeString); ASSERT_TRUE(stream->Write(request)); if (i % 1000 == 0) { - gpr_log(GPR_INFO, "Send count = %d", i); + LOG(INFO) << "Send count = " << i; } } stream->WritesDone(); diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index 0c4b51610f4..45460855a10 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -22,6 +22,8 @@ #include +#include "absl/log/log.h" + #include #include #include @@ -285,8 +287,8 @@ static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs, if (!s.ok()) { if (!(allow_exhaustion && s.error_code() == StatusCode::RESOURCE_EXHAUSTED)) { - gpr_log(GPR_ERROR, "RPC error: %d: %s", s.error_code(), - s.error_message().c_str()); + LOG(ERROR) << "RPC error: " << s.error_code() << ": " + << s.error_message(); } gpr_atm_no_barrier_fetch_add(errors, gpr_atm{1}); } else { @@ -316,7 +318,7 @@ TYPED_TEST(End2endTest, ThreadStress) { } uint64_t error_cnt = static_cast(gpr_atm_no_barrier_load(&errors)); if (error_cnt != 0) { - gpr_log(GPR_INFO, "RPC error count: %" PRIu64, error_cnt); + LOG(INFO) << "RPC error count: " << error_cnt; } // If this test allows resource exhaustion, expect that it actually sees some if (this->common_.AllowExhaustion()) { @@ -375,7 +377,7 @@ class AsyncClientEnd2endTest : public ::testing::Test { if (!cq_.Next(&got_tag, &ok)) break; AsyncClientCall* call = static_cast(got_tag); if (!ok) { - gpr_log(GPR_DEBUG, "Error: %d", call->status.error_code()); + VLOG(2) << "Error: " << call->status.error_code(); } delete call; diff --git a/test/cpp/end2end/tls_credentials_test.cc b/test/cpp/end2end/tls_credentials_test.cc index 75a3981b8b1..9e9c69b257c 100644 --- a/test/cpp/end2end/tls_credentials_test.cc +++ b/test/cpp/end2end/tls_credentials_test.cc @@ -20,6 +20,7 @@ #include #include +#include "absl/log/log.h" #include "absl/synchronization/notification.h" #include @@ -114,9 +115,8 @@ void DoRpc(const std::string& server_addr, grpc::Status result = stub->Echo(&context, request, &response); EXPECT_TRUE(result.ok()); if (!result.ok()) { - gpr_log(GPR_ERROR, "Echo failed: %d, %s, %s", - static_cast(result.error_code()), - result.error_message().c_str(), result.error_details().c_str()); + LOG(ERROR) << "Echo failed: " << result.error_code() << ", " + << result.error_message() << ", " << result.error_details(); } EXPECT_EQ(response.message(), kMessage); } diff --git a/test/cpp/end2end/xds/xds_cluster_end2end_test.cc b/test/cpp/end2end/xds/xds_cluster_end2end_test.cc index a162086b69e..e8f37fc35e8 100644 --- a/test/cpp/end2end/xds/xds_cluster_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_cluster_end2end_test.cc @@ -913,8 +913,7 @@ TEST_P(EdsTest, LocalityMapUpdateChurn) { } const double kErrorTolerance = 0.2; for (size_t i = 0; i < 3; ++i) { - gpr_log(GPR_INFO, "Locality %" PRIuPTR " rate %f", i, - locality_picked_rates[i]); + LOG(INFO) << "Locality " << i << " rate " << locality_picked_rates[i]; EXPECT_THAT( locality_picked_rates[i], ::testing::AllOf( @@ -947,8 +946,7 @@ TEST_P(EdsTest, LocalityMapUpdateChurn) { kNumRpcs); } for (size_t i = 1; i < 4; ++i) { - gpr_log(GPR_INFO, "Locality %" PRIuPTR " rate %f", i, - locality_picked_rates[i]); + LOG(INFO) << "Locality " << i << " rate " << locality_picked_rates[i]; EXPECT_THAT( locality_picked_rates[i], ::testing::AllOf( @@ -1099,7 +1097,7 @@ TEST_P(EdsTest, DropConfigUpdate) { LOG(INFO) << "========= DONE WITH FIRST BATCH =========="; // The drop rate should be roughly equal to the expectation. double seen_drop_rate = static_cast(num_drops) / kNumRpcsLbOnly; - gpr_log(GPR_INFO, "First batch drop rate %f", seen_drop_rate); + LOG(INFO) << "First batch drop rate " << seen_drop_rate; EXPECT_THAT(seen_drop_rate, ::testing::DoubleNear(kDropRateForLb, kErrorTolerance)); // The second ADS response contains two drop categories, send an update EDS @@ -1136,7 +1134,7 @@ TEST_P(EdsTest, DropConfigUpdate) { LOG(INFO) << "========= DONE WITH SECOND BATCH =========="; // The new drop rate should be roughly equal to the expectation. seen_drop_rate = static_cast(num_drops) / kNumRpcsBoth; - gpr_log(GPR_INFO, "Second batch drop rate %f", seen_drop_rate); + LOG(INFO) << "Second batch drop rate " << seen_drop_rate; EXPECT_THAT(seen_drop_rate, ::testing::DoubleNear(kDropRateForLbAndThrottle, kErrorTolerance)); } diff --git a/test/cpp/end2end/xds/xds_core_end2end_test.cc b/test/cpp/end2end/xds/xds_core_end2end_test.cc index ebc97f4a8e8..abc1d20cf06 100644 --- a/test/cpp/end2end/xds/xds_core_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_core_end2end_test.cc @@ -22,6 +22,7 @@ #include #include +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "src/core/client_channel/backup_poller.h" @@ -150,9 +151,9 @@ TEST_P(XdsClientTest, XdsStreamErrorPropagation) { balancer_->ads_service()->ForceADSFailure( Status(StatusCode::RESOURCE_EXHAUSTED, kErrorMessage)); auto status = SendRpc(); - gpr_log(GPR_INFO, - "XdsStreamErrorPropagation test: RPC got error: code=%d message=%s", - status.error_code(), status.error_message().c_str()); + LOG(INFO) << "XdsStreamErrorPropagation test: RPC got error: code=" + << status.error_code() + << " message=" << status.error_message().c_str(); EXPECT_THAT(status.error_code(), StatusCode::UNAVAILABLE); EXPECT_THAT(status.error_message(), ::testing::HasSubstr(kErrorMessage)); EXPECT_THAT(status.error_message(), @@ -288,8 +289,8 @@ TEST_P(GlobalXdsClientTest, MultipleBadLdsResources) { response->error_message == expected_message2) { return response; } - gpr_log(GPR_INFO, "non-matching NACK message: %s", - response->error_message.c_str()); + LOG(INFO) << "non-matching NACK message: " + << response->error_message.c_str(); } return absl::nullopt; }); diff --git a/test/cpp/end2end/xds/xds_csds_end2end_test.cc b/test/cpp/end2end/xds/xds_csds_end2end_test.cc index 897fd298148..cf498e060f8 100644 --- a/test/cpp/end2end/xds/xds_csds_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_csds_end2end_test.cc @@ -20,6 +20,7 @@ #include #include +#include "absl/log/log.h" #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" #include "absl/strings/strip.h" @@ -343,7 +344,7 @@ TEST_P(ClientStatusDiscoveryServiceTest, XdsConfigDumpVanilla) { CheckRpcSendOk(DEBUG_LOCATION, kNumRpcs); // Fetches the client config auto csds_response = FetchCsdsResponse(); - gpr_log(GPR_INFO, "xDS config dump: %s", csds_response.DebugString().c_str()); + LOG(INFO) << "xDS config dump: " << csds_response.DebugString(); ASSERT_EQ(1, csds_response.config_size()); const auto& client_config = csds_response.config(0); // Validate the Node information diff --git a/test/cpp/end2end/xds/xds_end2end_test.cc b/test/cpp/end2end/xds/xds_end2end_test.cc index 9a8c8a9c52d..10f6e5febf1 100644 --- a/test/cpp/end2end/xds/xds_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_end2end_test.cc @@ -1077,15 +1077,16 @@ class XdsServerSecurityTest : public XdsEnd2endTest { } if (expected_status.has_value() && *expected_status != status.error_code()) { - gpr_log(GPR_ERROR, - "Expected status does not match Actual(%d) vs Expected(%d)", - status.error_code(), *expected_status); + LOG(ERROR) << "Expected status does not match Actual(" + << status.error_code() << ") vs Expected(" + << *expected_status << ")"; continue; } } else { if (!status.ok()) { - gpr_log(GPR_ERROR, "RPC failed. code=%d message=%s Trying again.", - status.error_code(), status.error_message().c_str()); + LOG(ERROR) << "RPC failed. code=" << status.error_code() + << " message=" << status.error_message() + << " Trying again."; continue; } EXPECT_EQ(response.message(), kRequestMessage); @@ -1095,23 +1096,21 @@ class XdsServerSecurityTest : public XdsEnd2endTest { std::string(entry.data(), entry.size()).c_str()); } if (peer_identity != expected_server_identity) { - gpr_log(GPR_ERROR, - "Expected server identity does not match. (actual) %s vs " - "(expected) %s Trying again.", - absl::StrJoin(peer_identity, ",").c_str(), - absl::StrJoin(expected_server_identity, ",").c_str()); + LOG(ERROR) << "Expected server identity does not match. (actual) " + << absl::StrJoin(peer_identity, ",") << " vs (expected) " + << absl::StrJoin(expected_server_identity, ",") + << " Trying again."; continue; } if (backends_[0]->backend_service()->last_peer_identity() != expected_client_identity) { - gpr_log( - GPR_ERROR, - "Expected client identity does not match. (actual) %s vs " - "(expected) %s Trying again.", - absl::StrJoin( - backends_[0]->backend_service()->last_peer_identity(), ",") - .c_str(), - absl::StrJoin(expected_client_identity, ",").c_str()); + LOG(ERROR) + << "Expected client identity does not match. (actual) " + << absl::StrJoin( + backends_[0]->backend_service()->last_peer_identity(), ",") + << " vs (expected) " + << absl::StrJoin(expected_client_identity, ",") + << " Trying again."; continue; } } diff --git a/test/cpp/end2end/xds/xds_end2end_test_lib.cc b/test/cpp/end2end/xds/xds_end2end_test_lib.cc index efccd9e0fb6..08d305c2a8a 100644 --- a/test/cpp/end2end/xds/xds_end2end_test_lib.cc +++ b/test/cpp/end2end/xds/xds_end2end_test_lib.cc @@ -27,6 +27,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -135,7 +136,7 @@ class XdsEnd2endTest::ServerThread::XdsChannelArgsServerBuilderOption // void XdsEnd2endTest::ServerThread::Start() { - gpr_log(GPR_INFO, "starting %s server on port %d", Type(), port_); + LOG(INFO) << "starting " << Type() << " server on port " << port_; CHECK(!running_); running_ = true; StartAllServices(); @@ -147,38 +148,38 @@ void XdsEnd2endTest::ServerThread::Start() { thread_ = std::make_unique( std::bind(&ServerThread::Serve, this, &mu, &cond)); cond.Wait(&mu); - gpr_log(GPR_INFO, "%s server startup complete", Type()); + LOG(INFO) << Type() << " server startup complete"; } void XdsEnd2endTest::ServerThread::Shutdown() { if (!running_) return; - gpr_log(GPR_INFO, "%s about to shutdown", Type()); + LOG(INFO) << Type() << " about to shutdown"; ShutdownAllServices(); server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0)); thread_->join(); - gpr_log(GPR_INFO, "%s shutdown completed", Type()); + LOG(INFO) << Type() << " shutdown completed"; running_ = false; } void XdsEnd2endTest::ServerThread::StopListeningAndSendGoaways() { - gpr_log(GPR_INFO, "%s sending GOAWAYs", Type()); + LOG(INFO) << Type() << " sending GOAWAYs"; { grpc_core::ExecCtx exec_ctx; auto* server = grpc_core::Server::FromC(server_->c_server()); server->StopListening(); server->SendGoaways(); } - gpr_log(GPR_INFO, "%s done sending GOAWAYs", Type()); + LOG(INFO) << Type() << " done sending GOAWAYs"; } void XdsEnd2endTest::ServerThread::StopListening() { - gpr_log(GPR_INFO, "%s about to stop listening", Type()); + LOG(INFO) << Type() << " about to stop listening"; { grpc_core::ExecCtx exec_ctx; auto* server = grpc_core::Server::FromC(server_->c_server()); server->StopListening(); } - gpr_log(GPR_INFO, "%s stopped listening", Type()); + LOG(INFO) << Type() << " stopped listening"; } void XdsEnd2endTest::ServerThread::Serve(grpc_core::Mutex* mu, @@ -758,10 +759,8 @@ size_t XdsEnd2endTest::WaitForAllBackends( << debug_location.file() << ":" << debug_location.line(); }; } - gpr_log(GPR_INFO, - "========= WAITING FOR BACKENDS [%" PRIuPTR ", %" PRIuPTR - ") ==========", - start_index, stop_index); + LOG(INFO) << "========= WAITING FOR BACKENDS [" << start_index << ", " + << stop_index << ") =========="; size_t num_rpcs = 0; SendRpcsUntil( debug_location, @@ -772,8 +771,7 @@ size_t XdsEnd2endTest::WaitForAllBackends( }, wait_options.timeout_ms, rpc_options); if (wait_options.reset_counters) ResetBackendCounters(); - gpr_log(GPR_INFO, "Backends up; sent %" PRIuPTR " warm up requests", - num_rpcs); + LOG(INFO) << "Backends up; sent " << num_rpcs << " warm up requests"; return num_rpcs; } diff --git a/test/cpp/end2end/xds/xds_end2end_test_lib.h b/test/cpp/end2end/xds/xds_end2end_test_lib.h index af68e2b1c60..7ac0474a9f4 100644 --- a/test/cpp/end2end/xds/xds_end2end_test_lib.h +++ b/test/cpp/end2end/xds/xds_end2end_test_lib.h @@ -26,6 +26,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" @@ -946,10 +947,8 @@ class XdsEnd2endTest : public ::testing::TestWithParam, size_t num_rpcs = ceil(p * (1 - p) * 5.00 * 5.00 / error_tolerance / error_tolerance); num_rpcs += 1000; // Add 1K as a buffer to avoid flakiness. - gpr_log(GPR_INFO, - "Sending %" PRIuPTR - " RPCs for percentage=%.3f error_tolerance=%.3f", - num_rpcs, p, error_tolerance); + LOG(INFO) << "Sending " << num_rpcs << " RPCs for percentage=" << p + << " error_tolerance=" << error_tolerance; return num_rpcs; } diff --git a/test/cpp/end2end/xds/xds_override_host_end2end_test.cc b/test/cpp/end2end/xds/xds_override_host_end2end_test.cc index 4e8bce1cdc5..b02ab1ae2ef 100644 --- a/test/cpp/end2end/xds/xds_override_host_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_override_host_end2end_test.cc @@ -18,6 +18,7 @@ #include #include +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "absl/strings/str_split.h" @@ -89,8 +90,8 @@ class OverrideHostTest : public XdsEnd2endTest { absl::StrSplit(key_value.second, ';'); std::string decoded; EXPECT_TRUE(absl::Base64Unescape(key_value2.first, &decoded)); - gpr_log(GPR_INFO, "set-cookie header: %s (decoded: %s)", - std::string(it->second).c_str(), decoded.c_str()); + LOG(INFO) << "set-cookie header: " << it->second + << " (decoded: " << decoded << ")"; values.emplace_back(ParseCookie(it->second)); EXPECT_FALSE(values.back().value.empty()); EXPECT_THAT(values.back().attributes, ::testing::Contains("HttpOnly")); diff --git a/test/cpp/end2end/xds/xds_routing_end2end_test.cc b/test/cpp/end2end/xds/xds_routing_end2end_test.cc index e9f3fbd0ad7..e24e78f3273 100644 --- a/test/cpp/end2end/xds/xds_routing_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_routing_end2end_test.cc @@ -20,6 +20,8 @@ #include #include +#include "absl/log/log.h" + #include "src/core/client_channel/backup_poller.h" #include "src/core/lib/config/config_vars.h" #include "src/proto/grpc/testing/xds/v3/fault.grpc.pb.h" @@ -979,8 +981,9 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedCluster) { EXPECT_EQ(0, backends_[2]->backend_service()->request_count()); const int weight_25_request_count = backends_[2]->backend_service1()->request_count(); - gpr_log(GPR_INFO, "target_75 received %d rpcs and target_25 received %d rpcs", - weight_75_request_count, weight_25_request_count); + LOG(INFO) << "target_75 received " << weight_75_request_count + << " rpcs and target_25 received " << weight_25_request_count + << " rpcs"; EXPECT_THAT(static_cast(weight_75_request_count) / kNumEcho1Rpcs, ::testing::DoubleNear(kWeight75Percent, kErrorTolerance)); EXPECT_THAT(static_cast(weight_25_request_count) / kNumEcho1Rpcs, @@ -1061,8 +1064,9 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterNoIntegerOverflow) { EXPECT_EQ(0, backends_[2]->backend_service()->request_count()); const int weight2_request_count = backends_[2]->backend_service1()->request_count(); - gpr_log(GPR_INFO, "target1 received %d rpcs and target2 received %d rpcs", - weight1_request_count, weight2_request_count); + LOG(INFO) << "target1 received " << weight1_request_count + << " rpcs and target2 received " << weight2_request_count + << " rpcs"; EXPECT_THAT(static_cast(weight1_request_count) / kNumEcho1Rpcs, ::testing::DoubleNear(kWeight1Percent, kErrorTolerance)); EXPECT_THAT(static_cast(weight2_request_count) / kNumEcho1Rpcs, @@ -1129,8 +1133,9 @@ TEST_P(LdsRdsTest, RouteActionWeightedTargetDefaultRoute) { backends_[1]->backend_service()->request_count(); const int weight_25_request_count = backends_[2]->backend_service()->request_count(); - gpr_log(GPR_INFO, "target_75 received %d rpcs and target_25 received %d rpcs", - weight_75_request_count, weight_25_request_count); + LOG(INFO) << "target_75 received " << weight_75_request_count + << " rpcs and target_25 received " << weight_25_request_count + << " rpcs"; EXPECT_THAT(static_cast(weight_75_request_count) / kNumEchoRpcs, ::testing::DoubleNear(kWeight75Percent, kErrorTolerance)); EXPECT_THAT(static_cast(weight_25_request_count) / kNumEchoRpcs, @@ -1232,8 +1237,9 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateWeights) { backends_[2]->backend_service1()->request_count(); EXPECT_EQ(0, backends_[3]->backend_service()->request_count()); EXPECT_EQ(0, backends_[3]->backend_service1()->request_count()); - gpr_log(GPR_INFO, "target_75 received %d rpcs and target_25 received %d rpcs", - weight_75_request_count, weight_25_request_count); + LOG(INFO) << "target_75 received " << weight_75_request_count + << " rpcs and target_25 received " << weight_25_request_count + << " rpcs"; EXPECT_THAT(static_cast(weight_75_request_count) / kNumEcho1Rpcs7525, ::testing::DoubleNear(kWeight75Percent, kErrorTolerance)); EXPECT_THAT(static_cast(weight_25_request_count) / kNumEcho1Rpcs7525, @@ -1363,8 +1369,9 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) { EXPECT_EQ(0, backends_[2]->backend_service1()->request_count()); EXPECT_EQ(0, backends_[3]->backend_service()->request_count()); EXPECT_EQ(0, backends_[3]->backend_service1()->request_count()); - gpr_log(GPR_INFO, "target_75 received %d rpcs and target_25 received %d rpcs", - weight_75_request_count, weight_25_request_count); + LOG(INFO) << "target_75 received " << weight_75_request_count + << " rpcs and target_25 received " << weight_25_request_count + << " rpcs"; EXPECT_THAT(static_cast(weight_75_request_count) / kNumEcho1Rpcs7525, ::testing::DoubleNear(kWeight75Percent, kErrorTolerance)); EXPECT_THAT(static_cast(weight_25_request_count) / kNumEcho1Rpcs7525, @@ -1419,8 +1426,9 @@ TEST_P(LdsRdsTest, XdsRoutingWeightedClusterUpdateClusters) { EXPECT_EQ(0, backends_[2]->backend_service1()->request_count()); EXPECT_EQ(0, backends_[3]->backend_service()->request_count()); weight_25_request_count = backends_[3]->backend_service1()->request_count(); - gpr_log(GPR_INFO, "target_75 received %d rpcs and target_25 received %d rpcs", - weight_75_request_count, weight_25_request_count); + LOG(INFO) << "target_75 received " << weight_75_request_count + << " rpcs and target_25 received " << weight_25_request_count + << " rpcs"; EXPECT_THAT(static_cast(weight_75_request_count) / kNumEcho1Rpcs7525, ::testing::DoubleNear(kWeight75Percent, kErrorTolerance)); EXPECT_THAT(static_cast(weight_25_request_count) / kNumEcho1Rpcs7525, diff --git a/test/cpp/end2end/xds/xds_wrr_end2end_test.cc b/test/cpp/end2end/xds/xds_wrr_end2end_test.cc index 9a58443efa0..da8cea70f54 100644 --- a/test/cpp/end2end/xds/xds_wrr_end2end_test.cc +++ b/test/cpp/end2end/xds/xds_wrr_end2end_test.cc @@ -19,6 +19,7 @@ #include #include +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -84,10 +85,10 @@ TEST_P(WrrTest, Basic) { size_t num_picks = 0; SendRpcsUntil(DEBUG_LOCATION, [&](const RpcResult&) { if (++num_picks == 13) { - gpr_log(GPR_INFO, "request counts: %" PRIuPTR " %" PRIuPTR " %" PRIuPTR, - backends_[0]->backend_service()->request_count(), - backends_[1]->backend_service()->request_count(), - backends_[2]->backend_service()->request_count()); + LOG(INFO) << "request counts: " + << backends_[0]->backend_service()->request_count() << " " + << backends_[1]->backend_service()->request_count() << " " + << backends_[2]->backend_service()->request_count(); if (backends_[0]->backend_service()->request_count() == 6 && backends_[1]->backend_service()->request_count() == 4 && backends_[2]->backend_service()->request_count() == 3) { diff --git a/test/cpp/ext/filters/logging/library.h b/test/cpp/ext/filters/logging/library.h index bce76c1a228..92b7311c5a6 100644 --- a/test/cpp/ext/filters/logging/library.h +++ b/test/cpp/ext/filters/logging/library.h @@ -22,6 +22,7 @@ #include #include // NOLINT +#include "absl/log/log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "absl/time/time.h" @@ -58,10 +59,10 @@ class TestLoggingSink : public grpc_core::LoggingSink { grpc::internal::EntryToJsonStructProto(entry, &json); std::string output; ::google::protobuf::TextFormat::PrintToString(json, &output); - gpr_log(GPR_INFO, "%s", output.c_str()); - gpr_log(GPR_INFO, "trace_id: %s", entry.trace_id.c_str()); - gpr_log(GPR_INFO, "span_id: %s", entry.span_id.c_str()); - gpr_log(GPR_INFO, "is_sampled: %d", entry.is_sampled); + LOG(INFO) << output; + LOG(INFO) << "trace_id: " << entry.trace_id; + LOG(INFO) << "span_id: " << entry.span_id; + LOG(INFO) << "is_sampled: " << entry.is_sampled; grpc_core::MutexLock lock(&mu_); entries_.push_back(std::move(entry)); cv_.SignalAll(); diff --git a/test/cpp/interop/backend_metrics_lb_policy.cc b/test/cpp/interop/backend_metrics_lb_policy.cc index 216c537a9a6..55487bc221b 100644 --- a/test/cpp/interop/backend_metrics_lb_policy.cc +++ b/test/cpp/interop/backend_metrics_lb_policy.cc @@ -19,6 +19,7 @@ #include "test/cpp/interop/backend_metrics_lb_policy.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include @@ -264,7 +265,7 @@ LoadReportTracker::LoadReportEntry LoadReportTracker::WaitForOobLoadReport( auto report = std::move(oob_load_reports_.front()); oob_load_reports_.pop_front(); if (predicate(report)) { - gpr_log(GPR_DEBUG, "Report #%" PRIuPTR " matched", i + 1); + VLOG(2) << "Report #" << (i + 1) << " matched"; return report; } } diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 7d5a9dad71c..8a708c345da 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -20,10 +20,10 @@ #include #include "absl/flags/flag.h" +#include "absl/log/log.h" #include #include -#include #include #include #include @@ -186,8 +186,8 @@ ParseAdditionalMetadataFlag(const std::string& flag) { } } - gpr_log(GPR_INFO, "Adding additional metadata with key %s and value %s", - key.c_str(), value.c_str()); + LOG(INFO) << "Adding additional metadata with key " << key << " and value " + << value; additional_metadata.insert({key, value}); if (semicolon_pos == std::string::npos) { @@ -205,16 +205,14 @@ ParseAdditionalMetadataFlag(const std::string& flag) { int main(int argc, char** argv) { grpc::testing::TestEnvironment env(&argc, argv); grpc::testing::InitTest(&argc, &argv, true); - gpr_log(GPR_INFO, "Testing these cases: %s", - absl::GetFlag(FLAGS_test_case).c_str()); + LOG(INFO) << "Testing these cases: " << absl::GetFlag(FLAGS_test_case); int ret = 0; std::string test_case = absl::GetFlag(FLAGS_test_case); auto additional_metadata = ParseAdditionalMetadataFlag(absl::GetFlag(FLAGS_additional_metadata)); if (!additional_metadata.ok()) { - gpr_log(GPR_ERROR, "%s", - std::string(additional_metadata.status().message()).c_str()); + LOG(ERROR) << additional_metadata.status().message(); return 1; } grpc::testing::ChannelCreationFunc channel_creation_func = @@ -351,8 +349,9 @@ int main(int argc, char** argv) { if (!test_cases.empty()) test_cases += "\n"; test_cases += action.first; } - gpr_log(GPR_ERROR, "Unsupported test case %s. Valid options are\n%s", - absl::GetFlag(FLAGS_test_case).c_str(), test_cases.c_str()); + LOG(ERROR) << "Unsupported test case " << absl::GetFlag(FLAGS_test_case) + << ". Valid options are\n" + << test_cases; ret = 1; } diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index d9d10f1eeb9..8963aecc4ff 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -25,13 +25,13 @@ #include "absl/flags/declare.h" #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/escaping.h" #include "absl/strings/match.h" #include #include #include -#include #include #include #include @@ -70,7 +70,7 @@ std::string GetOauth2AccessToken() { std::shared_ptr creds = GoogleComputeEngineCredentials(); char* token = grpc_test_fetch_oauth2_token_with_credentials(creds->c_creds_); CHECK_NE(token, nullptr); - gpr_log(GPR_INFO, "Get raw oauth2 access token: %s", token); + LOG(INFO) << "Get raw oauth2 access token: " << token; std::string access_token(token + sizeof("Bearer ") - 1); gpr_free(token); return access_token; @@ -147,8 +147,7 @@ static void log_metadata_entry(const std::string& prefix, if (absl::EndsWith(key_str, "-bin")) { value_str = absl::Base64Escape(value_str); } - gpr_log(GPR_ERROR, "%s %s: %s", prefix.c_str(), key_str.c_str(), - value_str.c_str()); + LOG(ERROR) << prefix << " " << key_str << ": " << value_str; } void MetadataAndStatusLoggerInterceptor::Intercept( @@ -170,9 +169,8 @@ void MetadataAndStatusLoggerInterceptor::Intercept( } auto status = methods->GetRecvStatus(); - gpr_log(GPR_ERROR, "GRPC_STATUS %d", status->error_code()); - gpr_log(GPR_ERROR, "GRPC_ERROR_MESSAGE %s", - status->error_message().c_str()); + LOG(ERROR) << "GRPC_STATUS " << status->error_code(); + LOG(ERROR) << "GRPC_ERROR_MESSAGE " << status->error_message(); } methods->Proceed(); diff --git a/test/cpp/interop/istio_echo_server.cc b/test/cpp/interop/istio_echo_server.cc index 78175fdda9b..e81b1b2f170 100644 --- a/test/cpp/interop/istio_echo_server.cc +++ b/test/cpp/interop/istio_echo_server.cc @@ -30,6 +30,7 @@ #include "absl/algorithm/container.h" #include "absl/flags/flag.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "absl/strings/str_split.h" @@ -114,8 +115,7 @@ void RunServer(const std::set& grpc_ports, const std::set& xds_ports, if (xds_ports.find(port) != xds_ports.end()) { xds_builder.AddListeningPort( server_address, XdsServerCredentials(InsecureServerCredentials())); - gpr_log(GPR_INFO, "Server listening on %s over xds", - server_address.c_str()); + LOG(INFO) << "Server listening on " << server_address << " over xds"; has_xds_listeners = true; } else if (tls_ports.find(port) != tls_ports.end()) { // Create Credentials for Tls Servers - @@ -130,12 +130,10 @@ void RunServer(const std::set& grpc_ports, const std::set& xds_ports, options.watch_identity_key_cert_pairs(); options.set_check_call_host(false); builder.AddListeningPort(server_address, TlsServerCredentials(options)); - gpr_log(GPR_INFO, "Server listening on %s over tls", - server_address.c_str()); + LOG(INFO) << "Server listening on " << server_address << " over tls"; } else { builder.AddListeningPort(server_address, InsecureServerCredentials()); - gpr_log(GPR_INFO, "Server listening on %s over insecure", - server_address.c_str()); + LOG(INFO) << "Server listening on " << server_address << " over insecure"; } } // Enable the default health check service, probably not needed though. @@ -206,7 +204,7 @@ int main(int argc, char** argv) { for (const auto& p : absl::GetFlag(FLAGS_xds_grpc_server)) { int port = 0; if (!absl::SimpleAtoi(p, &port)) { - gpr_log(GPR_ERROR, "SimpleAtoi Failure: %s", p.c_str()); + LOG(ERROR) << "SimpleAtoi Failure: " << p; return 1; } xds_ports.insert(port); @@ -220,7 +218,7 @@ int main(int argc, char** argv) { for (const auto& p : absl::GetFlag(FLAGS_tls)) { int port = 0; if (!absl::SimpleAtoi(p, &port)) { - gpr_log(GPR_ERROR, "SimpleAtoi Failure: %s", p.c_str()); + LOG(ERROR) << "SimpleAtoi Failure: " << p; return 1; } tls_ports.insert(port); diff --git a/test/cpp/interop/istio_echo_server_lib.cc b/test/cpp/interop/istio_echo_server_lib.cc index b9b7d3d1b68..cb39a15cf99 100644 --- a/test/cpp/interop/istio_echo_server_lib.cc +++ b/test/cpp/interop/istio_echo_server_lib.cc @@ -18,6 +18,7 @@ #include +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_split.h" @@ -109,7 +110,7 @@ Status EchoTestServiceImpl::Echo(ServerContext* context, absl::StrAppend(&s, kHostnameField, "=", this->hostname_, "\n"); absl::StrAppend(&s, "Echo=", request->message(), "\n"); response->set_message(s); - gpr_log(GPR_INFO, "Echo response:\n%s", s.c_str()); + LOG(INFO) << "Echo response:\n" << s; return Status::OK; } @@ -129,8 +130,7 @@ Status EchoTestServiceImpl::ForwardEcho(ServerContext* context, if (scheme == "xds") { // We can optionally add support for TLS creds, but we are primarily // concerned with proxyless-grpc here. - gpr_log(GPR_INFO, "Creating channel to %s using xDS Creds", - raw_url.c_str()); + LOG(INFO) << "Creating channel to " << raw_url << " using xDS Creds"; channel = CreateChannel(raw_url, XdsCredentials(InsecureChannelCredentials())); } else if (scheme == "grpc") { @@ -138,11 +138,11 @@ Status EchoTestServiceImpl::ForwardEcho(ServerContext* context, // this to be supported. If we ever decide to add support for this properly, // we would need to add support for TLS creds here. absl::string_view address = absl::StripPrefix(raw_url, "grpc://"); - gpr_log(GPR_INFO, "Creating channel to %s", std::string(address).c_str()); + LOG(INFO) << "Creating channel to " << address; channel = CreateChannel(std::string(address), InsecureChannelCredentials()); } else { - gpr_log(GPR_INFO, "Protocol %s not supported. Forwarding to %s", - scheme.c_str(), forwarding_address_.c_str()); + LOG(INFO) << "Protocol " << scheme << " not supported. Forwarding to " + << forwarding_address_; ClientContext forwarding_ctx; forwarding_ctx.set_deadline(context->deadline()); return forwarding_stub_->ForwardEcho(&forwarding_ctx, *request, response); @@ -197,11 +197,10 @@ Status EchoTestServiceImpl::ForwardEcho(ServerContext* context, absl::StrAppend(&body, absl::StrFormat("[%d body] %s\n", i, line)); } response->add_output(body); - gpr_log(GPR_INFO, "Forward Echo response:%d\n%s", i, body.c_str()); + LOG(INFO) << "Forward Echo response:" << i << "\n" << body; } else { - gpr_log(GPR_ERROR, "RPC %d failed %d: %s", i, - calls[i].status.error_code(), - calls[i].status.error_message().c_str()); + LOG(ERROR) << "RPC " << i << " failed " << calls[i].status.error_code() + << ": " << calls[i].status.error_message(); response->clear_output(); return calls[i].status; } diff --git a/test/cpp/interop/observability_interop_server_bootstrap.cc b/test/cpp/interop/observability_interop_server_bootstrap.cc index 65287fb0d62..f14755b5cd9 100644 --- a/test/cpp/interop/observability_interop_server_bootstrap.cc +++ b/test/cpp/interop/observability_interop_server_bootstrap.cc @@ -19,6 +19,7 @@ #include #include "absl/flags/flag.h" +#include "absl/log/log.h" #include @@ -44,7 +45,7 @@ int main(int argc, char** argv) { // TODO(someone): remove deprecated usage // NOLINTNEXTLINE(clang-diagnostic-deprecated-declarations) auto status = grpc::experimental::GcpObservabilityInit(); - gpr_log(GPR_DEBUG, "GcpObservabilityInit() status_code: %d", status.code()); + VLOG(2) << "GcpObservabilityInit() status_code: " << status.code(); if (!status.ok()) { return 1; } diff --git a/test/cpp/interop/reconnect_interop_server.cc b/test/cpp/interop/reconnect_interop_server.cc index b5370bca397..656bf77e906 100644 --- a/test/cpp/interop/reconnect_interop_server.cc +++ b/test/cpp/interop/reconnect_interop_server.cc @@ -27,9 +27,9 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include -#include #include #include #include @@ -167,7 +167,7 @@ void RunServer() { builder.AddListeningPort(server_address.str(), grpc::InsecureServerCredentials()); std::unique_ptr server(builder.BuildAndStart()); - gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str()); + LOG(INFO) << "Server listening on " << server_address.str(); while (!got_sigint) { service.Poll(5); } diff --git a/test/cpp/interop/stress_interop_client.cc b/test/cpp/interop/stress_interop_client.cc index b99e31158fa..91a33d2547c 100644 --- a/test/cpp/interop/stress_interop_client.cc +++ b/test/cpp/interop/stress_interop_client.cc @@ -23,9 +23,9 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" -#include #include #include "src/core/lib/gprpp/crash.h" @@ -86,8 +86,8 @@ StressTestInteropClient::StressTestInteropClient( void StressTestInteropClient::MainLoop( const std::shared_ptr& qps_gauge) { - gpr_log(GPR_INFO, "Running test %d. ServerAddr: %s", test_id_, - server_address_.c_str()); + LOG(INFO) << "Running test " << test_id_ + << ". ServerAddr: " << server_address_; gpr_timespec test_end_time; if (test_duration_secs_ < 0) { @@ -103,7 +103,7 @@ void StressTestInteropClient::MainLoop( while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), test_end_time) < 0) { // Select the test case to execute based on the weights and execute it TestCaseType test_case = test_selector_.GetNextTest(); - gpr_log(GPR_DEBUG, "%d - Executing the test case %d", test_id_, test_case); + VLOG(2) << test_id_ << " - Executing the test case " << test_case; RunTest(test_case); qps_gauge->Incr(); diff --git a/test/cpp/interop/xds_interop_server_lib.cc b/test/cpp/interop/xds_interop_server_lib.cc index 12a26b16497..d1ee23381af 100644 --- a/test/cpp/interop/xds_interop_server_lib.cc +++ b/test/cpp/interop/xds_interop_server_lib.cc @@ -20,11 +20,11 @@ #include +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include -#include #include #include #include @@ -192,7 +192,7 @@ absl::optional GetStatusForRpcBehaviorMetadata( absl::string_view header_value, absl::string_view hostname) { for (auto part : absl::StrSplit(header_value, ' ')) { if (absl::ConsumePrefix(&part, kHostnameRpcBehaviorFilter)) { - gpr_log(GPR_INFO, "%s", std::string(part).c_str()); + LOG(INFO) << part; if (part.empty()) { return Status( grpc::StatusCode::INVALID_ARGUMENT, @@ -200,10 +200,8 @@ absl::optional GetStatusForRpcBehaviorMetadata( header_value)); } if (part != hostname) { - gpr_log( - GPR_DEBUG, - "RPC behavior for a different host: \"%s\", this one is: \"%s\"", - std::string(part).c_str(), std::string(hostname).c_str()); + VLOG(2) << "RPC behavior for a different host: \"" << std::string(part) + << "\", this one is: \"" << hostname << "\""; return absl::nullopt; } } else if (absl::ConsumePrefix(&part, kErrorCodeRpcBehavior)) { @@ -245,15 +243,14 @@ void RunServer(bool secure_mode, bool enable_csm_observability, int port, absl::StrCat("0.0.0.0:", port), grpc::XdsServerCredentials(grpc::InsecureServerCredentials())); xds_enabled_server = xds_builder.BuildAndStart(); - gpr_log(GPR_INFO, "Server starting on 0.0.0.0:%d", port); + LOG(INFO) << "Server starting on 0.0.0.0:" << port; ServerBuilder builder; maintenance_services.AddToServerBuilder(&builder); server = builder .AddListeningPort(absl::StrCat("0.0.0.0:", maintenance_port), grpc::InsecureServerCredentials()) .BuildAndStart(); - gpr_log(GPR_INFO, "Maintenance server listening on 0.0.0.0:%d", - maintenance_port); + LOG(INFO) << "Maintenance server listening on 0.0.0.0:" << maintenance_port; } else { // CSM Observability requires an xDS enabled server. auto builder = enable_csm_observability @@ -265,7 +262,7 @@ void RunServer(bool secure_mode, bool enable_csm_observability, int port, grpc::InsecureServerCredentials()) .RegisterService(&service) .BuildAndStart(); - gpr_log(GPR_INFO, "Server listening on 0.0.0.0:%d", port); + LOG(INFO) << "Server listening on 0.0.0.0:" << port; } server_callback(server.get()); server->Wait(); diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index a0c34cc9666..9c752a6342f 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -26,11 +26,11 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/random/random.h" #include #include -#include #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" @@ -135,7 +135,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) { logged_representative_output = true; for (size_t i = 0; i < outbuf.count; i++) { char* s = grpc_dump_slice(outbuf.slices[i], GPR_DUMP_HEX); - gpr_log(GPR_DEBUG, "%" PRIdPTR ": %s", i, s); + VLOG(2) << i << ": " << s; gpr_free(s); } } diff --git a/test/cpp/naming/address_sorting_test.cc b/test/cpp/naming/address_sorting_test.cc index 0ce5a1d5150..563ce7d8a36 100644 --- a/test/cpp/naming/address_sorting_test.cc +++ b/test/cpp/naming/address_sorting_test.cc @@ -25,10 +25,10 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include #include -#include #include #include #include @@ -120,8 +120,7 @@ class MockSourceAddrFactory : public address_sorting_source_addr_factory { .value(); auto it = dest_addr_to_src_addr_.find(ip_addr_str); if (it == dest_addr_to_src_addr_.end()) { - gpr_log(GPR_DEBUG, "can't find |%s| in dest to src map", - ip_addr_str.c_str()); + VLOG(2) << "can't find |" << ip_addr_str << "| in dest to src map"; return false; } grpc_resolved_address source_addr_as_resolved_addr = diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 78909d9eb17..d42e5f7dda1 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -28,6 +28,7 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/memory/memory.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -35,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -241,8 +241,8 @@ void PollPollsetUntilRequestDone(ArgsStruct* args) { } gpr_timespec time_left = gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME)); - gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", args->done, - time_left.tv_sec, time_left.tv_nsec); + VLOG(2) << "done=" << args->done << ", time_left=" << time_left.tv_sec + << "." << absl::StrFormat("%09d", time_left.tv_nsec); CHECK_GE(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)), 0); grpc_pollset_worker* worker = nullptr; grpc_core::ExecCtx exec_ctx; @@ -342,11 +342,11 @@ class CheckingResultHandler : public ResultHandler { AddActualAddresses(*balancer_addresses, /*is_balancer=*/true, &found_lb_addrs); } - gpr_log(GPR_INFO, - "found %" PRIdPTR " backend addresses and %" PRIdPTR - " balancer addresses", - result.addresses->size(), - balancer_addresses == nullptr ? 0L : balancer_addresses->size()); + LOG(INFO) << "found " << result.addresses->size() + << " backend addresses and " + << (balancer_addresses == nullptr ? 0L + : balancer_addresses->size()) + << " balancer addresses"; if (args->expected_addrs.size() != found_lb_addrs.size()) { grpc_core::Crash(absl::StrFormat("found lb addrs size is: %" PRIdPTR ". expected addrs size is %" PRIdPTR, @@ -359,10 +359,10 @@ class CheckingResultHandler : public ResultHandler { EXPECT_THAT(args->expected_addrs, UnorderedElementsAreArray(found_lb_addrs)); } else { - gpr_log(GPR_ERROR, - "Invalid for setting for --do_ordered_address_comparison. " - "Have %s, want True or False", - absl::GetFlag(FLAGS_do_ordered_address_comparison).c_str()); + LOG(ERROR) << "Invalid for setting for --do_ordered_address_comparison. " + "Have " + << absl::GetFlag(FLAGS_do_ordered_address_comparison) + << ", want True or False"; CHECK(0); } if (!result.service_config.ok()) { @@ -389,7 +389,7 @@ class CheckingResultHandler : public ResultHandler { std::string str = grpc_sockaddr_to_string(&addr.address(), true /* normalize */) .value(); - gpr_log(GPR_INFO, "%s", str.c_str()); + LOG(INFO) << str; out->emplace_back(GrpcLBAddress(std::move(str), is_balancer)); } } @@ -409,11 +409,9 @@ void InjectBrokenNameServerList(ares_channel* channel) { CHECK(grpc_core::SplitHostPort( absl::GetFlag(FLAGS_local_dns_server_address).c_str(), &unused_host, &local_dns_server_port)); - gpr_log(GPR_DEBUG, - "Injecting broken nameserver list. Bad server address:|[::1]:%d|. " - "Good server address:%s", - g_fake_non_responsive_dns_server_port, - absl::GetFlag(FLAGS_local_dns_server_address).c_str()); + VLOG(2) << "Injecting broken nameserver list. Bad server address:|[::1]:" + << g_fake_non_responsive_dns_server_port << "|. Good server address:" + << absl::GetFlag(FLAGS_local_dns_server_address); // Put the non-responsive DNS server at the front of c-ares's nameserver list. dns_server_addrs[0].family = AF_INET6; (reinterpret_cast(&dns_server_addrs[0].addr.addr6))[15] = 0x1; @@ -450,9 +448,8 @@ void RunResolvesRelevantRecordsTest( args.expected_lb_policy = absl::GetFlag(FLAGS_expected_lb_policy); // maybe build the address with an authority std::string whole_uri; - gpr_log(GPR_DEBUG, - "resolver_component_test: --inject_broken_nameserver_list: %s", - absl::GetFlag(FLAGS_inject_broken_nameserver_list).c_str()); + VLOG(2) << "resolver_component_test: --inject_broken_nameserver_list: " + << absl::GetFlag(FLAGS_inject_broken_nameserver_list); std::unique_ptr fake_non_responsive_dns_server; if (absl::GetFlag(FLAGS_inject_broken_nameserver_list) == "True") { @@ -471,16 +468,16 @@ void RunResolvesRelevantRecordsTest( } whole_uri = absl::StrCat("dns:///", absl::GetFlag(FLAGS_target_name)); } else if (absl::GetFlag(FLAGS_inject_broken_nameserver_list) == "False") { - gpr_log(GPR_INFO, "Specifying authority in uris to: %s", - absl::GetFlag(FLAGS_local_dns_server_address).c_str()); + LOG(INFO) << "Specifying authority in uris to: " + << absl::GetFlag(FLAGS_local_dns_server_address); whole_uri = absl::StrFormat("dns://%s/%s", absl::GetFlag(FLAGS_local_dns_server_address), absl::GetFlag(FLAGS_target_name)); } else { grpc_core::Crash("Invalid value for --inject_broken_nameserver_list."); } - gpr_log(GPR_DEBUG, "resolver_component_test: --enable_srv_queries: %s", - absl::GetFlag(FLAGS_enable_srv_queries).c_str()); + VLOG(2) << "resolver_component_test: --enable_srv_queries: " + << absl::GetFlag(FLAGS_enable_srv_queries); // By default, SRV queries are disabled, so tests that expect no SRV query // should avoid setting any channel arg. Test cases that do rely on the SRV // query must explicitly enable SRV though. @@ -489,8 +486,8 @@ void RunResolvesRelevantRecordsTest( } else if (absl::GetFlag(FLAGS_enable_srv_queries) != "False") { grpc_core::Crash("Invalid value for --enable_srv_queries."); } - gpr_log(GPR_DEBUG, "resolver_component_test: --enable_txt_queries: %s", - absl::GetFlag(FLAGS_enable_txt_queries).c_str()); + VLOG(2) << "resolver_component_test: --enable_txt_queries: " + << absl::GetFlag(FLAGS_enable_txt_queries); // By default, TXT queries are disabled, so tests that expect no TXT query // should avoid setting any channel arg. Test cases that do rely on the TXT // query must explicitly enable TXT though. diff --git a/test/cpp/naming/resolver_component_tests_runner_invoker.cc b/test/cpp/naming/resolver_component_tests_runner_invoker.cc index c5e4dc7d8f1..4fb67300c5c 100644 --- a/test/cpp/naming/resolver_component_tests_runner_invoker.cc +++ b/test/cpp/naming/resolver_component_tests_runner_invoker.cc @@ -28,11 +28,11 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include #include -#include #include #include "src/core/lib/gprpp/crash.h" @@ -128,9 +128,8 @@ int main(int argc, char** argv) { // an indication whether the test is running on RBE or not. Find a better way of // doing this. #ifndef GRPC_PORT_ISOLATED_RUNTIME - gpr_log(GPR_ERROR, - "You are invoking the test locally with Bazel, you may need to " - "invoke Bazel with --enable_runfiles=yes."); + LOG(ERROR) << "You are invoking the test locally with Bazel, you may need " + "to invoke Bazel with --enable_runfiles=yes."; #endif // GRPC_PORT_ISOLATED_RUNTIME result = grpc::testing::InvokeResolverComponentTestsRunner( grpc::testing::NormalizeFilePath( diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc index 9bd8f009334..5811cbaee85 100644 --- a/test/cpp/performance/writes_per_rpc_test.cc +++ b/test/cpp/performance/writes_per_rpc_test.cc @@ -21,8 +21,8 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" -#include #include #include #include @@ -262,10 +262,9 @@ static double UnaryPingPong(ThreadedFuzzingEventEngine* fuzzing_engine, auto end_stats = grpc_core::global_stats().Collect()->Diff(*baseline); double writes_per_iteration = end_stats->syscall_write / static_cast(kIterations); - gpr_log(GPR_DEBUG, - "UnaryPingPong(%d, %d): writes_per_iteration=%0.3f (total=%lu)", - request_size, response_size, writes_per_iteration, - end_stats->syscall_write); + VLOG(2) << "UnaryPingPong(" << request_size << ", " << response_size + << "): writes_per_iteration=" << writes_per_iteration + << " (total=" << end_stats->syscall_write << ")"; fixture.reset(); server_env[0]->~ServerEnv(); diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 18f9b4bad6e..11fd6b89e62 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -28,11 +28,11 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/memory/memory.h" #include #include -#include #include #include #include @@ -227,7 +227,7 @@ class AsyncClient : public ClientImpl { int num_threads = config.async_client_threads(); if (num_threads <= 0) { // Use dynamic sizing num_threads = cores_; - gpr_log(GPR_INFO, "Sizing async client to %d threads", num_threads); + LOG(INFO) << "Sizing async client to " << num_threads << " threads"; } return num_threads; } diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index 92ed2c11fff..eb1d8aeea72 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -25,10 +25,10 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include #include -#include #include #include #include @@ -182,8 +182,8 @@ class SynchronousStreamingClient : public SynchronousClient { if (!s.ok()) { std::lock_guard l(stream_mu_[thread_idx]); if (!shutdown_[thread_idx].val) { - gpr_log(GPR_ERROR, "Stream %" PRIuPTR " received an error %s", - thread_idx, s.error_message().c_str()); + LOG(ERROR) << "Stream " << thread_idx << " received an error " + << s.error_message(); } } // Lock the stream_mu_ now because the client context could change diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc index cc44252ea2a..8bc842328c9 100644 --- a/test/cpp/qps/json_run_localhost.cc +++ b/test/cpp/qps/json_run_localhost.cc @@ -29,8 +29,7 @@ #endif #include "absl/log/check.h" - -#include +#include "absl/log/log.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/env.h" @@ -71,13 +70,13 @@ static void register_sighandler() { static void LogStatus(int status, const char* label) { if (WIFEXITED(status)) { - gpr_log(GPR_INFO, "%s: subprocess exited with status %d", label, - WEXITSTATUS(status)); + LOG(INFO) << label << ": subprocess exited with status " + << WEXITSTATUS(status); } else if (WIFSIGNALED(status)) { - gpr_log(GPR_INFO, "%s: subprocess terminated with signal %d", label, - WTERMSIG(status)); + LOG(INFO) << label << ": subprocess terminated with signal " + << WTERMSIG(status); } else { - gpr_log(GPR_INFO, "%s: unknown subprocess status: %d", label, status); + LOG(INFO) << label << ": unknown subprocess status: " << status; } } diff --git a/test/cpp/qps/parse_json.cc b/test/cpp/qps/parse_json.cc index c104550f4a1..e283c8eae7d 100644 --- a/test/cpp/qps/parse_json.cc +++ b/test/cpp/qps/parse_json.cc @@ -21,10 +21,9 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" -#include - #include "src/core/lib/gprpp/crash.h" namespace grpc { @@ -40,8 +39,8 @@ void ParseJson(const std::string& json, const std::string& type, type_resolver.get(), "type.googleapis.com/" + type, json, &binary); if (!status.ok()) { std::string errmsg(status.message()); - gpr_log(GPR_ERROR, "Failed to convert json to binary: errcode=%d msg=%s", - static_cast(status.code()), errmsg.c_str()); + LOG(ERROR) << "Failed to convert json to binary: errcode=" << status.code() + << " msg=" << errmsg; grpc_core::Crash(absl::StrFormat("JSON: %s", json.c_str())); } CHECK(msg->ParseFromString(binary)); diff --git a/test/cpp/qps/scenario_runner.cc b/test/cpp/qps/scenario_runner.cc index 1d8f6c82475..da08af6b619 100644 --- a/test/cpp/qps/scenario_runner.cc +++ b/test/cpp/qps/scenario_runner.cc @@ -13,8 +13,7 @@ // limitations under the License. #include "absl/flags/flag.h" - -#include +#include "absl/log/log.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/stats_data.h" @@ -40,7 +39,7 @@ static void RunScenario() { grpc_core::testing::GetFileContents(absl::GetFlag(FLAGS_loadtest_config)); Scenarios scenarios; ParseJson(json_str, "grpc.testing.Scenarios", &scenarios); - gpr_log(GPR_INFO, "Running %s", scenarios.scenarios(0).name().c_str()); + LOG(INFO) << "Running " << scenarios.scenarios(0).name(); const auto result = RunScenario(scenarios.scenarios(0).client_config(), 1, scenarios.scenarios(0).server_config(), 1, @@ -49,8 +48,8 @@ static void RunScenario() { kInsecureCredentialsType, {}, false, 0); GetReporter()->ReportQPS(*result); GetReporter()->ReportLatency(*result); - gpr_log(GPR_ERROR, "Global Stats:\n%s", - StatsAsJson(grpc_core::global_stats().Collect().get()).c_str()); + LOG(ERROR) << "Global Stats:\n" + << StatsAsJson(grpc_core::global_stats().Collect().get()); } } // namespace testing diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index 02d7fec717d..2413d2d566d 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -21,8 +21,9 @@ #include +#include "absl/log/log.h" + #include -#include #include #include #include @@ -133,8 +134,8 @@ class Server { channel_arg.int_value()); break; case ChannelArg::VALUE_NOT_SET: - gpr_log(GPR_ERROR, "Channel arg '%s' does not have a value", - channel_arg.name().c_str()); + LOG(ERROR) << "Channel arg '" << channel_arg.name() + << "' does not have a value"; break; } } diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 821a380c58d..16bb01e8960 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -23,9 +23,10 @@ #include #include +#include "absl/log/log.h" + #include #include -#include #include #include #include @@ -91,11 +92,9 @@ class AsyncQpsServerTest final : public grpc::testing::Server { int num_threads = config.async_server_threads(); if (num_threads <= 0) { // dynamic sizing num_threads = std::min(64, cores()); - gpr_log(GPR_INFO, - "Sizing async server to %d threads. Defaults to number of cores " - "in machine or 64 threads if machine has more than 64 cores to " - "avoid OOMs.", - num_threads); + LOG(INFO) << "Sizing async server to " << num_threads + << " threads. Defaults to number of cores in machine or 64 " + "threads if machine has more than 64 cores to avoid OOMs."; } int tpc = std::max(1, config.threads_per_cq()); // 1 if unspecified @@ -111,9 +110,9 @@ class AsyncQpsServerTest final : public grpc::testing::Server { server_ = builder->BuildAndStart(); if (server_ == nullptr) { - gpr_log(GPR_ERROR, "Server: Fail to BuildAndStart(port=%d)", port_num); + LOG(ERROR) << "Server: Fail to BuildAndStart(port=" << port_num << ")"; } else { - gpr_log(GPR_INFO, "Server: BuildAndStart(port=%d)", port_num); + LOG(INFO) << "Server: BuildAndStart(port=" << port_num << ")"; } auto process_rpc_bound = diff --git a/test/cpp/qps/server_callback.cc b/test/cpp/qps/server_callback.cc index bb2f2f16c3d..c198b3d86b0 100644 --- a/test/cpp/qps/server_callback.cc +++ b/test/cpp/qps/server_callback.cc @@ -15,6 +15,9 @@ // limitations under the License. // // + +#include "absl/log/log.h" + #include #include #include @@ -113,9 +116,9 @@ class CallbackServer final : public grpc::testing::Server { impl_ = builder->BuildAndStart(); if (impl_ == nullptr) { - gpr_log(GPR_ERROR, "Server: Fail to BuildAndStart(port=%d)", port_num); + LOG(ERROR) << "Server: Fail to BuildAndStart(port=" << port_num << ")"; } else { - gpr_log(GPR_INFO, "Server: BuildAndStart(port=%d)", port_num); + LOG(INFO) << "Server: BuildAndStart(port=" << port_num << ")"; } } diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc index f78e17c2157..59a688d9b3e 100644 --- a/test/cpp/qps/server_sync.cc +++ b/test/cpp/qps/server_sync.cc @@ -19,6 +19,8 @@ #include #include +#include "absl/log/log.h" + #include #include #include @@ -171,9 +173,9 @@ class SynchronousServer final : public grpc::testing::Server { impl_ = builder->BuildAndStart(); if (impl_ == nullptr) { - gpr_log(GPR_ERROR, "Server: Fail to BuildAndStart(port=%d)", port_num); + LOG(ERROR) << "Server: Fail to BuildAndStart(port=" << port_num << ")"; } else { - gpr_log(GPR_INFO, "Server: BuildAndStart(port=%d)", port_num); + LOG(INFO) << "Server: BuildAndStart(port=" << port_num << ")"; } } diff --git a/test/cpp/thread_manager/thread_manager_test.cc b/test/cpp/thread_manager/thread_manager_test.cc index 1b3c8ba00f9..6c7eb3a3f34 100644 --- a/test/cpp/thread_manager/thread_manager_test.cc +++ b/test/cpp/thread_manager/thread_manager_test.cc @@ -26,7 +26,8 @@ #include -#include +#include "absl/log/log.h" + #include #include @@ -163,7 +164,7 @@ TEST_P(ThreadManagerTest, TestPollAndWork) { for (auto& tm : thread_manager_) { // Verify that The number of times DoWork() was called is equal to the // number of times WORK_FOUND was returned - gpr_log(GPR_DEBUG, "DoWork() called %d times", tm->num_do_work()); + VLOG(2) << "DoWork() called " << tm->num_do_work() << " times"; EXPECT_GE(tm->num_poll_for_work(), GetParam().max_poll_calls); EXPECT_EQ(tm->num_do_work(), tm->num_work_found()); }