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

[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 #36678

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36678 from tanvi-jagtap:test_cpp_gpr_log 81b8f4179f
PiperOrigin-RevId: 636410944
pull/35290/merge
Tanvi Jagtap 6 months ago committed by Copybara-Service
parent 46d864aaac
commit 154081a92a
  1. 4
      src/objective-c/tests/CFStreamTests/CFStreamClientTests.mm
  2. 2
      src/objective-c/tests/CFStreamTests/CFStreamEndpointTests.mm
  3. 4
      test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm
  4. 2
      test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm
  5. 10
      test/cpp/common/time_jump_test.cc
  6. 8
      test/cpp/common/timer_test.cc
  7. 4
      test/cpp/end2end/async_end2end_test.cc
  8. 11
      test/cpp/end2end/client_callback_end2end_test.cc
  9. 4
      test/cpp/end2end/client_crash_test_server.cc
  10. 4
      test/cpp/end2end/context_allocator_end2end_test.cc
  11. 6
      test/cpp/end2end/crl_provider_test.cc
  12. 19
      test/cpp/end2end/hybrid_end2end_test.cc
  13. 4
      test/cpp/end2end/message_allocator_end2end_test.cc
  14. 6
      test/cpp/end2end/mock_test.cc
  15. 16
      test/cpp/end2end/port_sharing_end2end_test.cc
  16. 9
      test/cpp/end2end/rls_end2end_test.cc
  17. 4
      test/cpp/end2end/server_crash_test.cc
  18. 5
      test/cpp/end2end/server_crash_test_client.cc
  19. 4
      test/cpp/end2end/shutdown_test.cc
  20. 4
      test/cpp/end2end/ssl_credentials_test.cc
  21. 5
      test/cpp/end2end/streaming_throughput_test.cc
  22. 10
      test/cpp/end2end/thread_stress_test.cc
  23. 6
      test/cpp/end2end/tls_credentials_test.cc
  24. 10
      test/cpp/end2end/xds/xds_cluster_end2end_test.cc
  25. 11
      test/cpp/end2end/xds/xds_core_end2end_test.cc
  26. 3
      test/cpp/end2end/xds/xds_csds_end2end_test.cc
  27. 35
      test/cpp/end2end/xds/xds_end2end_test.cc
  28. 26
      test/cpp/end2end/xds/xds_end2end_test_lib.cc
  29. 7
      test/cpp/end2end/xds/xds_end2end_test_lib.h
  30. 5
      test/cpp/end2end/xds/xds_override_host_end2end_test.cc
  31. 32
      test/cpp/end2end/xds/xds_routing_end2end_test.cc
  32. 9
      test/cpp/end2end/xds/xds_wrr_end2end_test.cc
  33. 9
      test/cpp/ext/filters/logging/library.h
  34. 3
      test/cpp/interop/backend_metrics_lb_policy.cc
  35. 17
      test/cpp/interop/client.cc
  36. 12
      test/cpp/interop/client_helper.cc
  37. 14
      test/cpp/interop/istio_echo_server.cc
  38. 19
      test/cpp/interop/istio_echo_server_lib.cc
  39. 3
      test/cpp/interop/observability_interop_server_bootstrap.cc
  40. 4
      test/cpp/interop/reconnect_interop_server.cc
  41. 8
      test/cpp/interop/stress_interop_client.cc
  42. 17
      test/cpp/interop/xds_interop_server_lib.cc
  43. 4
      test/cpp/microbenchmarks/bm_chttp2_hpack.cc
  44. 5
      test/cpp/naming/address_sorting_test.cc
  45. 51
      test/cpp/naming/resolver_component_test.cc
  46. 7
      test/cpp/naming/resolver_component_tests_runner_invoker.cc
  47. 9
      test/cpp/performance/writes_per_rpc_test.cc
  48. 4
      test/cpp/qps/client_async.cc
  49. 6
      test/cpp/qps/client_sync.cc
  50. 13
      test/cpp/qps/json_run_localhost.cc
  51. 7
      test/cpp/qps/parse_json.cc
  52. 9
      test/cpp/qps/scenario_runner.cc
  53. 7
      test/cpp/qps/server.h
  54. 15
      test/cpp/qps/server_async.cc
  55. 7
      test/cpp/qps/server_callback.cc
  56. 6
      test/cpp/qps/server_sync.cc
  57. 5
      test/cpp/thread_manager/thread_manager_test.cc

@ -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());

@ -112,7 +112,7 @@ static bool compare_slice_buffer_with_buffer(grpc_slice_buffer *slices, const ch
std::promise<grpc_error_handle> 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<struct sockaddr_in *>(resolved_addr->addr);

@ -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());

@ -111,7 +111,7 @@ static bool compare_slice_buffer_with_buffer(grpc_slice_buffer *slices, const ch
std::promise<grpc_error_handle> 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<struct sockaddr_in *>(resolved_addr->addr);

@ -26,10 +26,10 @@
#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/time/time.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#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);
}

@ -21,9 +21,9 @@
#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#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

@ -21,13 +21,13 @@
#include <thread>
#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 <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
@ -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 {};

@ -26,6 +26,7 @@
#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/memory/memory.h"
#include <grpcpp/channel.h>
@ -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<EchoRequest> {
}
}
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<EchoResponse> {
}
}
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<EchoRequest, EchoResponse> {
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 ||

@ -21,8 +21,8 @@
#include <string>
#include "absl/flags/flag.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
@ -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);
}

@ -28,8 +28,8 @@
#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
@ -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

@ -22,6 +22,7 @@
#include <gtest/gtest.h>
#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 <grpc/grpc_crl_provider.h>
#include <grpc/grpc_security.h>
#include <grpc/support/log.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
@ -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 {

@ -22,6 +22,7 @@
#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpcpp/channel.h>
@ -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<int>(context->deadline().time_since_epoch().count()));
VLOG(2) << "Constructor of generic service "
<< context->deadline().time_since_epoch().count();
class Reactor : public ServerGenericBidiReactor {
public:

@ -29,8 +29,8 @@
#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
@ -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

@ -22,10 +22,10 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/log/log.h"
#include "absl/types/optional.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
@ -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);
}

@ -22,10 +22,10 @@
#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
@ -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<int>(p.read_buffer.Length()), listener_fd_);
LOG(INFO) << "Handing off fd " << fd_ << " with data size "
<< static_cast<int>(p.read_buffer.Length())
<< " from listener fd " << listener_fd_;
connection_acceptor_->HandleNewConnection(&p);
}
@ -224,8 +225,7 @@ class PortSharingEnd2endTest : public ::testing::TestWithParam<TestScenario> {
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);

@ -29,6 +29,7 @@
#include <gtest/gtest.h>
#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>(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::thread>(
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;
}

@ -19,10 +19,10 @@
#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/memory/memory.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
@ -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),

@ -23,8 +23,8 @@
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
@ -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;
}
}

@ -21,9 +21,9 @@
#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
@ -132,7 +132,7 @@ std::vector<string> 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;
}

@ -20,6 +20,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/log/log.h"
#include "absl/synchronization/notification.h"
#include <grpc/credentials.h>
@ -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<const AuthContext> auth_context = context.auth_context();

@ -23,9 +23,10 @@
#include <gtest/gtest.h>
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
@ -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();

@ -22,6 +22,8 @@
#include <gtest/gtest.h>
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/time.h>
#include <grpcpp/channel.h>
@ -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<uint64_t>(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<AsyncClientCall*>(got_tag);
if (!ok) {
gpr_log(GPR_DEBUG, "Error: %d", call->status.error_code());
VLOG(2) << "Error: " << call->status.error_code();
}
delete call;

@ -20,6 +20,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/log/log.h"
#include "absl/synchronization/notification.h"
#include <grpc/grpc_security.h>
@ -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<int>(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);
}

@ -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<double>(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<double>(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));
}

@ -22,6 +22,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#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;
});

@ -20,6 +20,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#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

@ -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;
}
}

@ -27,6 +27,7 @@
#include <gtest/gtest.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"
@ -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::thread>(
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;
}

@ -26,6 +26,7 @@
#include <gtest/gtest.h>
#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<XdsTestType>,
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;
}

@ -18,6 +18,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#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"));

@ -20,6 +20,8 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#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<double>(weight_75_request_count) / kNumEcho1Rpcs,
::testing::DoubleNear(kWeight75Percent, kErrorTolerance));
EXPECT_THAT(static_cast<double>(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<double>(weight1_request_count) / kNumEcho1Rpcs,
::testing::DoubleNear(kWeight1Percent, kErrorTolerance));
EXPECT_THAT(static_cast<double>(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<double>(weight_75_request_count) / kNumEchoRpcs,
::testing::DoubleNear(kWeight75Percent, kErrorTolerance));
EXPECT_THAT(static_cast<double>(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<double>(weight_75_request_count) / kNumEcho1Rpcs7525,
::testing::DoubleNear(kWeight75Percent, kErrorTolerance));
EXPECT_THAT(static_cast<double>(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<double>(weight_75_request_count) / kNumEcho1Rpcs7525,
::testing::DoubleNear(kWeight75Percent, kErrorTolerance));
EXPECT_THAT(static_cast<double>(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<double>(weight_75_request_count) / kNumEcho1Rpcs7525,
::testing::DoubleNear(kWeight75Percent, kErrorTolerance));
EXPECT_THAT(static_cast<double>(weight_25_request_count) / kNumEcho1Rpcs7525,

@ -19,6 +19,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#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) {

@ -22,6 +22,7 @@
#include <chrono>
#include <thread> // 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();

@ -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 <grpc/support/port_platform.h>
@ -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;
}
}

@ -20,10 +20,10 @@
#include <unordered_map>
#include "absl/flags/flag.h"
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/support/channel_arguments.h>
@ -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;
}

@ -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 <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpcpp/channel.h>
#include <grpcpp/create_channel.h>
#include <grpcpp/security/credentials.h>
@ -70,7 +70,7 @@ std::string GetOauth2AccessToken() {
std::shared_ptr<CallCredentials> 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();

@ -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<int>& grpc_ports, const std::set<int>& 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<int>& grpc_ports, const std::set<int>& 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);

@ -18,6 +18,7 @@
#include <thread>
#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;
}

@ -19,6 +19,7 @@
#include <signal.h>
#include "absl/flags/flag.h"
#include "absl/log/log.h"
#include <grpcpp/ext/gcp_observability.h>
@ -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;
}

@ -27,9 +27,9 @@
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>
#include <grpcpp/server_context.h>
@ -167,7 +167,7 @@ void RunServer() {
builder.AddListeningPort(server_address.str(),
grpc::InsecureServerCredentials());
std::unique_ptr<Server> 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);
}

@ -23,9 +23,9 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include <grpc/support/log.h>
#include <grpcpp/create_channel.h>
#include "src/core/lib/gprpp/crash.h"
@ -86,8 +86,8 @@ StressTestInteropClient::StressTestInteropClient(
void StressTestInteropClient::MainLoop(
const std::shared_ptr<QpsGauge>& 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();

@ -20,11 +20,11 @@
#include <memory>
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_split.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpcpp/ext/admin_services.h>
#include <grpcpp/ext/proto_server_reflection_plugin.h>
@ -192,7 +192,7 @@ absl::optional<grpc::Status> 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<grpc::Status> 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();

@ -26,11 +26,11 @@
#include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/random/random.h"
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#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);
}
}

@ -25,10 +25,10 @@
#include <gmock/gmock.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
@ -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 =

@ -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 <grpc/grpc.h>
#include <grpc/impl/grpc_types.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
@ -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<char*>(&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<grpc_core::testing::FakeUdpAndTcpServer>
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.

@ -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 <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#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(

@ -21,8 +21,8 @@
#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpcpp/channel.h>
#include <grpcpp/create_channel.h>
#include <grpcpp/impl/grpc_library.h>
@ -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<double>(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();

@ -28,11 +28,11 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/memory/memory.h"
#include <grpc/grpc.h>
#include <grpc/support/cpu.h>
#include <grpc/support/log.h>
#include <grpcpp/alarm.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
@ -227,7 +227,7 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
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;
}

@ -25,10 +25,10 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
@ -182,8 +182,8 @@ class SynchronousStreamingClient : public SynchronousClient {
if (!s.ok()) {
std::lock_guard<std::mutex> 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

@ -29,8 +29,7 @@
#endif
#include "absl/log/check.h"
#include <grpc/support/log.h>
#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;
}
}

@ -21,10 +21,9 @@
#include <string>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include <grpc/support/log.h>
#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<int>(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));

@ -13,8 +13,7 @@
// limitations under the License.
#include "absl/flags/flag.h"
#include <grpc/support/log.h>
#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

@ -21,8 +21,9 @@
#include <vector>
#include "absl/log/log.h"
#include <grpc/support/cpu.h>
#include <grpc/support/log.h>
#include <grpcpp/channel.h>
#include <grpcpp/resource_quota.h>
#include <grpcpp/security/server_credentials.h>
@ -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;
}
}

@ -23,9 +23,10 @@
#include <mutex>
#include <thread>
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpcpp/generic/async_generic_service.h>
#include <grpcpp/resource_quota.h>
#include <grpcpp/security/server_credentials.h>
@ -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 =

@ -15,6 +15,9 @@
// limitations under the License.
//
//
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpcpp/security/server_credentials.h>
@ -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 << ")";
}
}

@ -19,6 +19,8 @@
#include <atomic>
#include <thread>
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpcpp/security/server_credentials.h>
@ -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 << ")";
}
}

@ -26,7 +26,8 @@
#include <gtest/gtest.h>
#include <grpc/support/log.h>
#include "absl/log/log.h"
#include <grpc/support/port_platform.h>
#include <grpcpp/grpcpp.h>
@ -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());
}

Loading…
Cancel
Save