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

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

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36703 from tanvi-jagtap:test_core_gpr_log_01 26c4307b08
PiperOrigin-RevId: 636801504
pull/36701/head^2
Tanvi Jagtap 9 months ago committed by Copybara-Service
parent d148728588
commit 0ed095093c
  1. 11
      test/core/security/alts_security_connector_test.cc
  2. 17
      test/core/security/credentials_test.cc
  3. 5
      test/core/security/json_token_test.cc
  4. 6
      test/core/security/oauth2_utils.cc
  5. 17
      test/core/slice/percent_encoding_test.cc
  6. 6
      test/core/slice/slice_string_helpers_test.cc
  7. 22
      test/core/surface/byte_buffer_reader_test.cc
  8. 6
      test/core/surface/num_external_connectivity_watchers_test.cc
  9. 6
      test/core/surface/sequential_connectivity_test.cc
  10. 4
      test/core/surface/server_test.cc
  11. 5
      test/core/test_util/cmdline_test.cc
  12. 94
      test/core/test_util/fake_stats_plugin.h
  13. 97
      test/core/test_util/fake_udp_and_tcp_server.cc
  14. 9
      test/core/test_util/fuzzer_corpus_test.cc
  15. 14
      test/core/test_util/grpc_profiler.cc
  16. 15
      test/core/test_util/histogram_test.cc
  17. 9
      test/core/test_util/port_server_client.cc
  18. 5
      test/core/test_util/stack_tracer_test.cc
  19. 11
      test/core/test_util/test_lb_policies.cc
  20. 4
      test/core/test_util/test_tcp_server.cc
  21. 4
      test/core/transport/chaotic_good/chaotic_good_server_test.cc
  22. 9
      test/core/transport/chaotic_good/frame_fuzzer.cc
  23. 6
      test/core/transport/chttp2/bin_decoder_test.cc
  24. 15
      test/core/transport/chttp2/bin_encoder_test.cc
  25. 5
      test/core/transport/chttp2/hpack_utils_test.cc
  26. 45
      test/core/transport/chttp2/stream_leak_with_queued_flow_control_update_test.cc
  27. 5
      test/core/transport/chttp2/varint_test.cc
  28. 9
      test/core/transport/test_suite/test.h
  29. 5
      test/core/tsi/alts/fake_handshaker/fake_handshaker_server_main.cc
  30. 4
      test/core/tsi/transport_security_test.cc
  31. 9
      test/core/util/env_test.cc
  32. 7
      test/core/xds/xds_transport_fake.cc

@ -24,9 +24,10 @@
#include <gtest/gtest.h>
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/security/context/security_context.h"
@ -144,13 +145,13 @@ static bool test_identity(const grpc_auth_context* ctx,
prop = grpc_auth_property_iterator_next(&it);
EXPECT_NE(prop, nullptr);
if (strcmp(prop->name, expected_property_name) != 0) {
gpr_log(GPR_ERROR, "Expected peer identity property name %s and got %s.",
expected_property_name, prop->name);
LOG(ERROR) << "Expected peer identity property name "
<< expected_property_name << " and got " << prop->name;
return false;
}
if (strncmp(prop->value, expected_identity, prop->value_length) != 0) {
gpr_log(GPR_ERROR, "Expected peer identity %s and got %s.",
expected_identity, prop->value);
LOG(ERROR) << "Expected peer identity " << expected_identity << " and got "
<< prop->value;
return false;
}
return true;

@ -37,7 +37,6 @@
#include <grpc/grpc_security.h>
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
@ -495,9 +494,8 @@ class RequestMetadataState : public RefCounted<RequestMetadataState> {
};
void CheckRequestMetadata(grpc_error_handle error) {
gpr_log(GPR_INFO, "expected_error: %s",
StatusToString(expected_error_).c_str());
gpr_log(GPR_INFO, "actual_error: %s", StatusToString(error).c_str());
LOG(INFO) << "expected_error: " << StatusToString(expected_error_);
LOG(INFO) << "actual_error: " << StatusToString(error);
if (expected_error_.ok()) {
CHECK_OK(error);
} else {
@ -511,8 +509,8 @@ class RequestMetadataState : public RefCounted<RequestMetadataState> {
}
md_.Remove(HttpAuthorityMetadata());
md_.Remove(HttpPathMetadata());
gpr_log(GPR_INFO, "expected metadata: %s", expected_.c_str());
gpr_log(GPR_INFO, "actual metadata: %s", md_.DebugString().c_str());
LOG(INFO) << "expected metadata: " << expected_;
LOG(INFO) << "actual metadata: " << md_.DebugString();
}
grpc_error_handle expected_error_;
@ -1011,8 +1009,7 @@ void assert_query_parameters(const URI& uri, absl::string_view expected_key,
const auto it = uri.query_parameter_map().find(expected_key);
CHECK(it != uri.query_parameter_map().end());
if (it->second != expected_val) {
gpr_log(GPR_ERROR, "%s!=%s", std::string(it->second).c_str(),
std::string(expected_val).c_str());
LOG(ERROR) << it->second << "!=" << expected_val;
}
CHECK(it->second == expected_val);
}
@ -1028,7 +1025,7 @@ void validate_sts_token_http_request(const grpc_http_request* request,
absl::StrFormat("%s?%s", test_sts_endpoint_url, body);
absl::StatusOr<URI> url = URI::Parse(get_url_equivalent);
if (!url.ok()) {
gpr_log(GPR_ERROR, "%s", url.status().ToString().c_str());
LOG(ERROR) << url.status();
CHECK_OK(url);
}
assert_query_parameters(*url, "resource", "resource");
@ -2115,7 +2112,7 @@ void validate_external_account_creds_token_exchage_request(
absl::StrFormat("%s?%s", "https://foo.com:5555/token", body);
absl::StatusOr<URI> uri = URI::Parse(get_url_equivalent);
if (!uri.ok()) {
gpr_log(GPR_ERROR, "%s", uri.status().ToString().c_str());
LOG(ERROR) << uri.status().ToString();
CHECK_OK(uri);
}
assert_query_parameters(*uri, "audience", "audience");

@ -23,13 +23,13 @@
#include <gtest/gtest.h>
#include <openssl/evp.h>
#include "absl/log/log.h"
#include "absl/strings/escaping.h"
#include <grpc/credentials.h>
#include <grpc/grpc_security.h>
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h"
@ -220,8 +220,7 @@ static Json parse_json_part_from_jwt(const char* str, size_t len) {
EXPECT_FALSE(decoded.empty());
auto json = grpc_core::JsonParse(decoded);
if (!json.ok()) {
gpr_log(GPR_ERROR, "JSON parse error: %s",
json.status().ToString().c_str());
LOG(ERROR) << "JSON parse error: " << json.status().ToString();
return Json();
}
return std::move(*json);

@ -20,12 +20,13 @@
#include <string.h>
#include "absl/log/log.h"
#include <grpc/credentials.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
@ -74,8 +75,7 @@ char* grpc_test_fetch_oauth2_token_with_credentials(
[&is_done, &done, &token, &initial_metadata](absl::Status result) {
is_done = true;
if (!result.ok()) {
gpr_log(GPR_ERROR, "Fetching token failed: %s",
result.ToString().c_str());
LOG(ERROR) << "Fetching token failed: " << result;
} else {
std::string buffer;
token = gpr_strdup(

@ -23,10 +23,10 @@
#include <memory>
#include <utility>
#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/util/string.h"
@ -46,7 +46,7 @@ static void test_vector(const char* raw, size_t raw_length, const char* encoded,
char* raw_msg = gpr_dump(raw, raw_length, GPR_DUMP_HEX | GPR_DUMP_ASCII);
char* encoded_msg =
gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", raw_msg, encoded_msg);
VLOG(2) << "Trial:\nraw = " << raw_msg << "\nencoded = " << encoded_msg;
gpr_free(raw_msg);
gpr_free(encoded_msg);
@ -61,10 +61,8 @@ static void test_vector(const char* raw, size_t raw_length, const char* encoded,
GPR_DUMP_HEX | GPR_DUMP_ASCII);
char* encoded2raw_permissive_msg = grpc_dump_slice(
encoded2raw_permissive_slice.c_slice(), GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG,
"Result:\nraw2encoded = %s\nencoded2raw_permissive "
"= %s",
raw2encoded_msg, encoded2raw_permissive_msg);
VLOG(2) << "Result:\nraw2encoded = " << raw2encoded_msg
<< "\nencoded2raw_permissive = " << encoded2raw_permissive_msg;
gpr_free(raw2encoded_msg);
gpr_free(encoded2raw_permissive_msg);
@ -81,8 +79,8 @@ static void test_nonconformant_vector(const char* encoded,
GPR_DUMP_HEX | GPR_DUMP_ASCII);
char* encoded_msg =
gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", permissive_unencoded_msg,
encoded_msg);
VLOG(2) << "Trial:\nraw = " << permissive_unencoded_msg
<< "\nencoded = " << encoded_msg;
gpr_free(permissive_unencoded_msg);
gpr_free(encoded_msg);
@ -95,8 +93,7 @@ static void test_nonconformant_vector(const char* encoded,
char* encoded2raw_permissive_msg = grpc_dump_slice(
encoded2raw_permissive_slice.c_slice(), GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "Result:\nencoded2raw_permissive = %s",
encoded2raw_permissive_msg);
VLOG(2) << "Result:\nencoded2raw_permissive = " << encoded2raw_permissive_msg;
gpr_free(encoded2raw_permissive_msg);
ASSERT_EQ(permissive_unencoded_slice, encoded2raw_permissive_slice);

@ -20,15 +20,13 @@
#include <memory>
#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/util/string.h"
#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
static void expect_slice_dump(grpc_slice slice, uint32_t flags,
const char* result) {
char* got = grpc_dump_slice(slice, flags);
@ -46,7 +44,7 @@ TEST(SliceStringHelpersTest, DumpSlice) {
"Victory Mansions, though not quickly enough to prevent a swirl of "
"gritty dust from entering along with him.";
LOG_TEST_NAME("test_dump_slice");
LOG(INFO) << "test_dump_slice";
expect_slice_dump(grpc_slice_from_copied_string(text), GPR_DUMP_ASCII, text);
expect_slice_dump(grpc_slice_from_copied_string(long_text), GPR_DUMP_ASCII,

@ -20,6 +20,7 @@
#include <memory>
#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <grpc/byte_buffer.h>
@ -27,12 +28,9 @@
#include <grpc/compression.h>
#include <grpc/grpc.h>
#include <grpc/slice.h>
#include <grpc/support/log.h>
#include "test/core/test_util/test_config.h"
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x)
TEST(GrpcByteBufferReaderTest, TestReadOneSlice) {
grpc_slice slice;
grpc_byte_buffer* buffer;
@ -40,7 +38,7 @@ TEST(GrpcByteBufferReaderTest, TestReadOneSlice) {
grpc_slice first_slice, second_slice;
int first_code, second_code;
LOG_TEST("test_read_one_slice");
LOG(INFO) << "test_read_one_slice";
slice = grpc_slice_from_copied_string("test");
buffer = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
@ -62,7 +60,7 @@ TEST(GrpcByteBufferReaderTest, TestReadOneSliceMalloc) {
grpc_slice first_slice, second_slice;
int first_code, second_code;
LOG_TEST("test_read_one_slice_malloc");
LOG(INFO) << "test_read_one_slice_malloc";
slice = grpc_slice_malloc(4);
memcpy(GRPC_SLICE_START_PTR(slice), "test", 4);
buffer = grpc_raw_byte_buffer_create(&slice, 1);
@ -85,7 +83,7 @@ TEST(GrpcByteBufferReaderTest, TestReadNoneCompressedSlice) {
grpc_slice first_slice, second_slice;
int first_code, second_code;
LOG_TEST("test_read_none_compressed_slice");
LOG(INFO) << "test_read_none_compressed_slice";
slice = grpc_slice_from_copied_string("test");
buffer = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
@ -108,7 +106,7 @@ TEST(GrpcByteBufferReaderTest, TestPeekOneSlice) {
grpc_slice* second_slice;
int first_code, second_code;
LOG_TEST("test_peek_one_slice");
LOG(INFO) << "test_peek_one_slice";
slice = grpc_slice_from_copied_string("test");
buffer = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
@ -130,7 +128,7 @@ TEST(GrpcByteBufferReaderTest, TestPeekOneSliceMalloc) {
grpc_slice* second_slice;
int first_code, second_code;
LOG_TEST("test_peek_one_slice_malloc");
LOG(INFO) << "test_peek_one_slice_malloc";
slice = grpc_slice_malloc(4);
memcpy(GRPC_SLICE_START_PTR(slice), "test", 4);
buffer = grpc_raw_byte_buffer_create(&slice, 1);
@ -153,7 +151,7 @@ TEST(GrpcByteBufferReaderTest, TestPeekNoneCompressedSlice) {
grpc_slice* second_slice;
int first_code, second_code;
LOG_TEST("test_peek_none_compressed_slice");
LOG(INFO) << "test_peek_none_compressed_slice";
slice = grpc_slice_from_copied_string("test");
buffer = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
@ -172,7 +170,7 @@ TEST(GrpcByteBufferReaderTest, TestByteBufferFromReader) {
grpc_byte_buffer *buffer, *buffer_from_reader;
grpc_byte_buffer_reader reader;
LOG_TEST("test_byte_buffer_from_reader");
LOG(INFO) << "test_byte_buffer_from_reader";
slice = grpc_slice_malloc(4);
memcpy(GRPC_SLICE_START_PTR(slice), "test", 4);
buffer = grpc_raw_byte_buffer_create(&slice, 1);
@ -201,7 +199,7 @@ TEST(GrpcByteBufferReaderTest, TestReadall) {
grpc_byte_buffer_reader reader;
grpc_slice slice_out;
LOG_TEST("test_readall");
LOG(INFO) << "test_readall";
memset(lotsa_as, 'a', 512 * sizeof(lotsa_as[0]));
memset(lotsa_bs, 'b', 1024 * sizeof(lotsa_bs[0]));
@ -235,7 +233,7 @@ TEST(GrpcByteBufferReaderTest, TestByteBufferCopy) {
grpc_byte_buffer_reader reader;
grpc_slice slice_out;
LOG_TEST("test_byte_buffer_copy");
LOG(INFO) << "test_byte_buffer_copy";
memset(lotsa_as, 'a', 512 * sizeof(lotsa_as[0]));
memset(lotsa_bs, 'b', 1024 * sizeof(lotsa_bs[0]));

@ -20,6 +20,7 @@
#include <string>
#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <grpc/credentials.h>
@ -27,7 +28,6 @@
#include <grpc/grpc_security.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/slice.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h"
@ -73,7 +73,7 @@ static void channel_idle_poll_for_timeout(grpc_channel* channel,
// Test to make sure that "connectivity watcher" structs are free'd just
// after, if their corresponding timeouts occur.
static void run_timeouts_test(const test_fixture* fixture) {
gpr_log(GPR_INFO, "TEST: %s", fixture->name);
LOG(INFO) << "TEST: " << fixture->name;
grpc_init();
std::string addr =
@ -122,7 +122,7 @@ static void run_timeouts_test(const test_fixture* fixture) {
// of a polling call.
static void run_channel_shutdown_before_timeout_test(
const test_fixture* fixture) {
gpr_log(GPR_INFO, "TEST: %s", fixture->name);
LOG(INFO) << "TEST: " << fixture->name;
grpc_init();
std::string addr =

@ -22,6 +22,7 @@
#include <string>
#include <vector>
#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <grpc/credentials.h>
@ -29,7 +30,6 @@
#include <grpc/grpc_security.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/slice.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h"
@ -94,8 +94,8 @@ static grpc_channel* create_test_channel(const char* addr,
}
static void run_test(const test_fixture* fixture, bool share_subchannel) {
gpr_log(GPR_INFO, "TEST: %s sharing subchannel: %d", fixture->name,
share_subchannel);
LOG(INFO) << "TEST: " << fixture->name
<< " sharing subchannel: " << share_subchannel;
std::string addr =
grpc_core::JoinHostPort("localhost", grpc_pick_unused_port_or_die());

@ -22,6 +22,7 @@
#include <string>
#include <vector>
#include "absl/log/log.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "gtest/gtest.h"
@ -30,7 +31,6 @@
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h"
@ -111,7 +111,7 @@ void test_bind_server_twice(void) {
void test_bind_server_to_addr(const char* host, bool secure) {
int port = grpc_pick_unused_port_or_die();
std::string addr = grpc_core::JoinHostPort(host, port);
gpr_log(GPR_INFO, "Test bind to %s", addr.c_str());
LOG(INFO) << "Test bind to " << addr;
grpc_server* server = grpc_server_create(nullptr, nullptr);
if (secure) {

@ -20,14 +20,13 @@
#include <string.h>
#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <grpc/support/log.h>
#include "src/core/util/useful.h"
#include "test/core/test_util/test_config.h"
#define LOG_TEST() gpr_log(GPR_INFO, "test at %s:%d", __FILE__, __LINE__)
#define LOG_TEST() LOG(INFO) << "test at " << __FILE__ << ":" << __LINE__
TEST(CmdlineTest, SimpleInt) {
int x = 1;

@ -22,6 +22,7 @@
#include "absl/container/flat_hash_map.h"
#include "absl/functional/any_invocable.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
@ -215,9 +216,8 @@ class FakeStatsPlugin : public StatsPlugin {
descriptor) {
if (!use_disabled_by_default_metrics &&
!descriptor.enable_by_default) {
gpr_log(GPR_INFO,
"FakeStatsPlugin[%p]: skipping disabled metric: %s", this,
std::string(descriptor.name).c_str());
LOG(INFO) << "FakeStatsPlugin[" << this
<< "]: skipping disabled metric: " << descriptor.name;
return;
}
switch (descriptor.instrument_type) {
@ -283,13 +283,12 @@ class FakeStatsPlugin : public StatsPlugin {
// just ignore it here. This would also prevent us from having to lock the
// GlobalInstrumentsRegistry everytime a metric is recorded. But this is not
// a concern for now.
gpr_log(GPR_INFO,
"FakeStatsPlugin[%p]::AddCounter(index=%u, value=(uint64)%" PRIu64
", "
"label_values={%s}, optional_label_values={%s}",
this, handle.index, value,
absl::StrJoin(label_values, ", ").c_str(),
absl::StrJoin(optional_values, ", ").c_str());
LOG(INFO) << "FakeStatsPlugin[" << this
<< "]::AddCounter(index=" << handle.index << ", value=(uint64)"
<< value << ", label_values={"
<< absl::StrJoin(label_values, ", ")
<< "}, optional_label_values={"
<< absl::StrJoin(optional_values, ", ") << "}";
MutexLock lock(&mu_);
auto iter = uint64_counters_.find(handle.index);
if (iter == uint64_counters_.end()) return;
@ -299,12 +298,12 @@ class FakeStatsPlugin : public StatsPlugin {
GlobalInstrumentsRegistry::GlobalInstrumentHandle handle, double value,
absl::Span<const absl::string_view> label_values,
absl::Span<const absl::string_view> optional_values) override {
gpr_log(GPR_INFO,
"FakeStatsPlugin[%p]::AddCounter(index=%u, value(double)=%f, "
"label_values={%s}, optional_label_values={%s}",
this, handle.index, value,
absl::StrJoin(label_values, ", ").c_str(),
absl::StrJoin(optional_values, ", ").c_str());
LOG(INFO) << "FakeStatsPlugin[" << this
<< "]::AddCounter(index=" << handle.index
<< ", value(double)=" << value << ", label_values={"
<< absl::StrJoin(label_values, ", ")
<< "}, optional_label_values={"
<< absl::StrJoin(optional_values, ", ") << "}";
MutexLock lock(&mu_);
auto iter = double_counters_.find(handle.index);
if (iter == double_counters_.end()) return;
@ -314,13 +313,12 @@ class FakeStatsPlugin : public StatsPlugin {
GlobalInstrumentsRegistry::GlobalInstrumentHandle handle, uint64_t value,
absl::Span<const absl::string_view> label_values,
absl::Span<const absl::string_view> optional_values) override {
gpr_log(
GPR_INFO,
"FakeStatsPlugin[%p]::RecordHistogram(index=%u, value=(uint64)%" PRIu64
", "
"label_values={%s}, optional_label_values={%s}",
this, handle.index, value, absl::StrJoin(label_values, ", ").c_str(),
absl::StrJoin(optional_values, ", ").c_str());
LOG(INFO) << "FakeStatsPlugin[" << this
<< "]::RecordHistogram(index=" << handle.index
<< ", value=(uint64)" << value << ", label_values={"
<< absl::StrJoin(label_values, ", ")
<< "}, optional_label_values={"
<< absl::StrJoin(optional_values, ", ") << "}";
MutexLock lock(&mu_);
auto iter = uint64_histograms_.find(handle.index);
if (iter == uint64_histograms_.end()) return;
@ -330,24 +328,25 @@ class FakeStatsPlugin : public StatsPlugin {
GlobalInstrumentsRegistry::GlobalInstrumentHandle handle, double value,
absl::Span<const absl::string_view> label_values,
absl::Span<const absl::string_view> optional_values) override {
gpr_log(GPR_INFO,
"FakeStatsPlugin[%p]::RecordHistogram(index=%u, value=(double)%f, "
"label_values={%s}, optional_label_values={%s}",
this, handle.index, value,
absl::StrJoin(label_values, ", ").c_str(),
absl::StrJoin(optional_values, ", ").c_str());
LOG(INFO) << "FakeStatsPlugin[" << this
<< "]::RecordHistogram(index=" << handle.index
<< ", value=(double)" << value << ", label_values={"
<< absl::StrJoin(label_values, ", ")
<< "}, optional_label_values={"
<< absl::StrJoin(optional_values, ", ") << "}";
MutexLock lock(&mu_);
auto iter = double_histograms_.find(handle.index);
if (iter == double_histograms_.end()) return;
iter->second.Record(value, label_values, optional_values);
}
void AddCallback(RegisteredMetricCallback* callback) override {
gpr_log(GPR_INFO, "FakeStatsPlugin[%p]::AddCallback(%p)", this, callback);
LOG(INFO) << "FakeStatsPlugin[" << this << "]::AddCallback(" << callback
<< ")";
callbacks_.insert(callback);
}
void RemoveCallback(RegisteredMetricCallback* callback) override {
gpr_log(GPR_INFO, "FakeStatsPlugin[%p]::RemoveCallback(%p)", this,
callback);
LOG(INFO) << "FakeStatsPlugin[" << this << "]::RemoveCallback(" << callback
<< ")";
callbacks_.erase(callback);
}
@ -406,12 +405,12 @@ class FakeStatsPlugin : public StatsPlugin {
return iter->second.GetValues(label_values, optional_values);
}
void TriggerCallbacks() {
gpr_log(GPR_INFO, "FakeStatsPlugin[%p]::TriggerCallbacks(): START", this);
LOG(INFO) << "FakeStatsPlugin[" << this << "]::TriggerCallbacks(): START";
Reporter reporter(*this);
for (auto* callback : callbacks_) {
callback->Run(reporter);
}
gpr_log(GPR_INFO, "FakeStatsPlugin[%p]::TriggerCallbacks(): END", this);
LOG(INFO) << "FakeStatsPlugin[" << this << "]::TriggerCallbacks(): END";
}
absl::optional<int64_t> GetInt64CallbackGaugeValue(
GlobalInstrumentsRegistry::GlobalInstrumentHandle handle,
@ -445,14 +444,12 @@ class FakeStatsPlugin : public StatsPlugin {
GlobalInstrumentsRegistry::GlobalInstrumentHandle handle, int64_t value,
absl::Span<const absl::string_view> label_values,
absl::Span<const absl::string_view> optional_values) override {
gpr_log(GPR_INFO,
"FakeStatsPlugin[%p]::Reporter::Report(index=%u, "
"value=(int64_t)%" PRId64
", label_values={%s}, "
"optional_label_values={%s}",
this, handle.index, value,
absl::StrJoin(label_values, ", ").c_str(),
absl::StrJoin(optional_values, ", ").c_str());
LOG(INFO) << "FakeStatsPlugin[" << this
<< "]::Reporter::Report(index=" << handle.index
<< ", value=(int64_t)" << value << ", label_values={"
<< absl::StrJoin(label_values, ", ")
<< "}, optional_label_values={"
<< absl::StrJoin(optional_values, ", ") << "}";
MutexLock lock(&plugin_.callback_mu_);
auto iter = plugin_.int64_callback_gauges_.find(handle.index);
if (iter == plugin_.int64_callback_gauges_.end()) return;
@ -463,13 +460,12 @@ class FakeStatsPlugin : public StatsPlugin {
GlobalInstrumentsRegistry::GlobalInstrumentHandle handle, double value,
absl::Span<const absl::string_view> label_values,
absl::Span<const absl::string_view> optional_values) override {
gpr_log(GPR_INFO,
"FakeStatsPlugin[%p]::Reporter::Report(index=%u, "
"value=(double)%f, label_values={%s}, "
"optional_label_values={%s}",
this, handle.index, value,
absl::StrJoin(label_values, ", ").c_str(),
absl::StrJoin(optional_values, ", ").c_str());
LOG(INFO) << "FakeStatsPlugin[" << this
<< "]::Reporter::Report(index=" << handle.index
<< ", value=(double)" << value << ", label_values={"
<< absl::StrJoin(label_values, ", ")
<< "}, optional_label_values={"
<< absl::StrJoin(optional_values, ", ") << "}";
MutexLock lock(&plugin_.callback_mu_);
auto iter = plugin_.double_callback_gauges_.find(handle.index);
if (iter == plugin_.double_callback_gauges_.end()) return;

@ -24,10 +24,10 @@
#include <vector>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/time.h>
@ -78,51 +78,49 @@ FakeUdpAndTcpServer::FakeUdpAndTcpServer(
port_ = grpc_pick_unused_port_or_die();
udp_socket_ = socket(AF_INET6, SOCK_DGRAM, 0);
if (udp_socket_ == BAD_SOCKET_RETURN_VAL) {
gpr_log(GPR_ERROR, "Failed to create UDP ipv6 socket: %d", ERRNO);
LOG(ERROR) << "Failed to create UDP ipv6 socket: " << ERRNO;
CHECK(0);
}
accept_socket_ = socket(AF_INET6, SOCK_STREAM, 0);
address_ = absl::StrCat("[::1]:", port_);
if (accept_socket_ == BAD_SOCKET_RETURN_VAL) {
gpr_log(GPR_ERROR, "Failed to create TCP IPv6 socket: %d", ERRNO);
LOG(ERROR) << "Failed to create TCP IPv6 socket: " << ERRNO;
CHECK(0);
}
#ifdef GPR_WINDOWS
char val = 1;
if (setsockopt(accept_socket_, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) ==
SOCKET_ERROR) {
gpr_log(GPR_ERROR,
"Failed to set SO_REUSEADDR on TCP ipv6 socket to [::1]:%d, "
"errno: %d",
port_, ERRNO);
LOG(ERROR) << "Failed to set SO_REUSEADDR on TCP ipv6 socket to [::1]:"
<< port_ << ", errno: " << ERRNO;
CHECK(0);
}
grpc_error_handle set_non_block_error;
set_non_block_error = grpc_tcp_set_non_block(udp_socket_);
if (!set_non_block_error.ok()) {
gpr_log(GPR_ERROR, "Failed to configure non-blocking socket: %s",
StatusToString(set_non_block_error).c_str());
LOG(ERROR) << "Failed to configure non-blocking socket: "
<< StatusToString(set_non_block_error);
CHECK(0);
}
set_non_block_error = grpc_tcp_set_non_block(accept_socket_);
if (!set_non_block_error.ok()) {
gpr_log(GPR_ERROR, "Failed to configure non-blocking socket: %s",
StatusToString(set_non_block_error).c_str());
LOG(ERROR) << "Failed to configure non-blocking socket: "
<< StatusToString(set_non_block_error);
CHECK(0);
}
#else
int val = 1;
if (setsockopt(accept_socket_, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) !=
0) {
gpr_log(GPR_ERROR, "Failed to set SO_REUSEADDR on socket [::1]:%d", port_);
LOG(ERROR) << "Failed to set SO_REUSEADDR on socket [::1]:" << port_;
CHECK(0);
}
if (fcntl(udp_socket_, F_SETFL, O_NONBLOCK) != 0) {
gpr_log(GPR_ERROR, "Failed to set O_NONBLOCK on socket: %d", ERRNO);
LOG(ERROR) << "Failed to set O_NONBLOCK on socket: " << ERRNO;
CHECK(0);
}
if (fcntl(accept_socket_, F_SETFL, O_NONBLOCK) != 0) {
gpr_log(GPR_ERROR, "Failed to set O_NONBLOCK on socket: %d", ERRNO);
LOG(ERROR) << "Failed to set O_NONBLOCK on socket: " << ERRNO;
CHECK(0);
}
#endif
@ -135,22 +133,21 @@ FakeUdpAndTcpServer::FakeUdpAndTcpServer(
memcpy(resolved_addr.addr, &addr, sizeof(addr));
resolved_addr.len = sizeof(addr);
std::string addr_str = grpc_sockaddr_to_string(&resolved_addr, false).value();
gpr_log(GPR_INFO, "Fake UDP and TCP server listening on %s",
addr_str.c_str());
LOG(INFO) << "Fake UDP and TCP server listening on " << addr_str;
if (bind(udp_socket_, reinterpret_cast<const sockaddr*>(&addr),
sizeof(addr)) != 0) {
gpr_log(GPR_ERROR, "Failed to bind UDP socket to [::1]:%d", port_);
LOG(ERROR) << "Failed to bind UDP socket to [::1]:" << port_;
CHECK(0);
}
if (bind(accept_socket_, reinterpret_cast<const sockaddr*>(&addr),
sizeof(addr)) != 0) {
gpr_log(GPR_ERROR, "Failed to bind TCP socket to [::1]:%d : %d", port_,
ERRNO);
LOG(ERROR) << "Failed to bind TCP socket to [::1]:" << port_ << " : "
<< ERRNO;
CHECK(0);
}
if (listen(accept_socket_, 100)) {
gpr_log(GPR_ERROR, "Failed to listen on socket bound to [::1]:%d : %d",
port_, ERRNO);
LOG(ERROR) << "Failed to listen on socket bound to [::1]:" << port_ << " : "
<< ERRNO;
CHECK(0);
}
gpr_event_init(&stop_ev_);
@ -159,14 +156,10 @@ FakeUdpAndTcpServer::FakeUdpAndTcpServer(
}
FakeUdpAndTcpServer::~FakeUdpAndTcpServer() {
gpr_log(GPR_DEBUG,
"FakeUdpAndTcpServer stop and "
"join server thread");
VLOG(2) << "FakeUdpAndTcpServer stop and join server thread";
gpr_event_set(&stop_ev_, reinterpret_cast<void*>(1));
run_server_loop_thd_->join();
gpr_log(GPR_DEBUG,
"FakeUdpAndTcpServer join server "
"thread complete");
VLOG(2) << "FakeUdpAndTcpServer join server thread complete";
CLOSE_SOCKET(accept_socket_);
CLOSE_SOCKET(udp_socket_);
}
@ -175,16 +168,13 @@ FakeUdpAndTcpServer::ProcessReadResult
FakeUdpAndTcpServer::CloseSocketUponReceivingBytesFromPeer(
int bytes_received_size, int read_error, int s) {
if (bytes_received_size < 0 && !ErrorIsRetryable(read_error)) {
gpr_log(GPR_ERROR, "Failed to receive from peer socket: %d. errno: %d", s,
read_error);
LOG(ERROR) << "Failed to receive from peer socket: " << s
<< ". errno: " << read_error;
CHECK(0);
}
if (bytes_received_size >= 0) {
gpr_log(GPR_DEBUG,
"Fake TCP server received %d bytes from peer socket: %d. Close "
"the "
"connection.",
bytes_received_size, s);
VLOG(2) << "Fake TCP server received " << bytes_received_size
<< " bytes from peer socket: " << s << ". Close the connection.";
return FakeUdpAndTcpServer::ProcessReadResult::kCloseSocket;
}
return FakeUdpAndTcpServer::ProcessReadResult::kContinueReading;
@ -194,17 +184,14 @@ FakeUdpAndTcpServer::ProcessReadResult
FakeUdpAndTcpServer::CloseSocketUponCloseFromPeer(int bytes_received_size,
int read_error, int s) {
if (bytes_received_size < 0 && !ErrorIsRetryable(read_error)) {
gpr_log(GPR_ERROR, "Failed to receive from peer socket: %d. errno: %d", s,
read_error);
LOG(ERROR) << "Failed to receive from peer socket: " << s
<< ". errno: " << read_error;
CHECK(0);
}
if (bytes_received_size == 0) {
// The peer has shut down the connection.
gpr_log(GPR_DEBUG,
"Fake TCP server received 0 bytes from peer socket: %d. Close "
"the "
"connection.",
s);
VLOG(2) << "Fake TCP server received 0 bytes from peer socket: " << s
<< ". Close the connection.";
return FakeUdpAndTcpServer::ProcessReadResult::kCloseSocket;
}
return FakeUdpAndTcpServer::ProcessReadResult::kContinueReading;
@ -214,21 +201,19 @@ FakeUdpAndTcpServer::ProcessReadResult
FakeUdpAndTcpServer::SendThreeAllZeroBytes(int bytes_received_size,
int read_error, int s) {
if (bytes_received_size < 0 && !ErrorIsRetryable(read_error)) {
gpr_log(GPR_ERROR, "Failed to receive from peer socket: %d. errno: %d", s,
read_error);
LOG(ERROR) << "Failed to receive from peer socket: " << s
<< ". errno: " << read_error;
CHECK(0);
}
if (bytes_received_size == 0) {
// The peer has shut down the connection.
gpr_log(GPR_DEBUG, "Fake TCP server received 0 bytes from peer socket: %d.",
s);
VLOG(2) << "Fake TCP server received 0 bytes from peer socket: " << s;
return FakeUdpAndTcpServer::ProcessReadResult::kCloseSocket;
}
char buf[3] = {0, 0, 0};
int bytes_sent = send(s, buf, sizeof(buf), 0);
gpr_log(GPR_DEBUG,
"Fake TCP server sent %d all-zero bytes on peer socket: %d.",
bytes_sent, s);
VLOG(2) << "Fake TCP server sent " << bytes_sent
<< " all-zero bytes on peer socket: " << s;
return FakeUdpAndTcpServer::ProcessReadResult::kCloseSocket;
}
@ -254,10 +239,8 @@ void FakeUdpAndTcpServer::FakeUdpAndTcpServerPeer::
send(fd_, kEmptyHttp2SettingsFrame.data() + total_bytes_sent_,
bytes_to_send, 0);
if (bytes_sent < 0 && !ErrorIsRetryable(ERRNO)) {
gpr_log(GPR_ERROR,
"Fake TCP server encountered unexpected error:%d "
"sending %d bytes on fd:%d",
ERRNO, bytes_to_send, fd_);
LOG(ERROR) << "Fake TCP server encountered unexpected error:" << ERRNO
<< " sending " << bytes_to_send << " bytes on fd:" << fd_;
CHECK(0);
} else if (bytes_sent > 0) {
total_bytes_sent_ += bytes_sent;
@ -277,19 +260,19 @@ void FakeUdpAndTcpServer::RunServerLoop() {
// handle TCP connections
int p = accept(accept_socket_, nullptr, nullptr);
if (p != BAD_SOCKET_RETURN_VAL) {
gpr_log(GPR_DEBUG, "accepted peer socket: %d", p);
VLOG(2) << "accepted peer socket: " << p;
#ifdef GPR_WINDOWS
grpc_error_handle set_non_block_error;
set_non_block_error = grpc_tcp_set_non_block(p);
if (!set_non_block_error.ok()) {
gpr_log(GPR_ERROR, "Failed to configure non-blocking socket: %s",
StatusToString(set_non_block_error).c_str());
LOG(ERROR) << "Failed to configure non-blocking socket: "
<< StatusToString(set_non_block_error);
CHECK(0);
}
#else
if (fcntl(p, F_SETFL, O_NONBLOCK) != 0) {
gpr_log(GPR_ERROR, "Failed to configure non-blocking socket, errno: %d",
ERRNO);
LOG(ERROR) << "Failed to configure non-blocking socket, errno: "
<< ERRNO;
CHECK(0);
}
#endif

@ -28,12 +28,12 @@
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/types/optional.h"
#include "gtest/gtest.h"
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/env.h"
#include "src/core/lib/iomgr/error.h"
@ -82,14 +82,15 @@ class ExampleGenerator
}
if (!absl::GetFlag(FLAGS_directory).empty()) {
auto test_srcdir = grpc_core::GetEnv("TEST_SRCDIR");
gpr_log(GPR_DEBUG, "test_srcdir=\"%s\"",
test_srcdir.has_value() ? test_srcdir->c_str() : "(null)");
VLOG(2) << "test_srcdir=\""
<< (test_srcdir.has_value() ? test_srcdir->c_str() : "(null)")
<< "\"";
std::string directory = absl::GetFlag(FLAGS_directory);
if (test_srcdir.has_value()) {
directory =
*test_srcdir + std::string("/com_github_grpc_grpc/") + directory;
}
gpr_log(GPR_DEBUG, "Using corpus directory: %s", directory.c_str());
VLOG(2) << "Using corpus directory: " << directory;
DIR* dp;
struct dirent* ep;
dp = opendir(directory.c_str());

@ -25,18 +25,16 @@ void grpc_profiler_start(const char* filename) { ProfilerStart(filename); }
void grpc_profiler_stop() { ProfilerStop(); }
#else
#include <grpc/support/log.h>
#include "absl/log/log.h"
void grpc_profiler_start(const char* filename) {
static int printed_warning = 0;
if (!printed_warning) {
gpr_log(GPR_DEBUG,
"You do not have google-perftools installed, profiling is disabled "
"[for %s]",
filename);
gpr_log(GPR_DEBUG,
"To install on ubuntu: sudo apt-get install google-perftools "
"libgoogle-perftools-dev");
VLOG(2) << "You do not have google-perftools installed, profiling is "
"disabled [for "
<< filename << "]";
VLOG(2) << "To install on ubuntu: sudo apt-get install google-perftools "
"libgoogle-perftools-dev";
printed_warning = 1;
}
}

@ -20,12 +20,9 @@
#include <memory>
#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <grpc/support/log.h>
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x);
TEST(HistogramTest, NoOp) {
grpc_histogram_destroy(grpc_histogram_create(0.01, 60e9));
}
@ -33,8 +30,8 @@ TEST(HistogramTest, NoOp) {
static void expect_percentile(grpc_histogram* h, double percentile,
double min_expect, double max_expect) {
double got = grpc_histogram_percentile(h, percentile);
gpr_log(GPR_INFO, "@%f%%, expect %f <= %f <= %f", percentile, min_expect, got,
max_expect);
LOG(INFO) << "@" << percentile << "%%, expect " << min_expect << " <= " << got
<< " <= " << max_expect;
ASSERT_LE(min_expect, got);
ASSERT_LE(got, max_expect);
}
@ -42,7 +39,7 @@ static void expect_percentile(grpc_histogram* h, double percentile,
TEST(HistogramTest, Simple) {
grpc_histogram* h;
LOG_TEST("test_simple");
LOG(INFO) << "test_simple";
h = grpc_histogram_create(0.01, 60e9);
grpc_histogram_add(h, 10000);
@ -62,7 +59,7 @@ TEST(HistogramTest, Percentile) {
double i;
double cur;
LOG_TEST("test_percentile");
LOG(INFO) << "test_percentile";
h = grpc_histogram_create(0.05, 1e9);
grpc_histogram_add(h, 2.5);
@ -107,7 +104,7 @@ TEST(HistogramTest, Merge) {
double i;
double cur;
LOG_TEST("test_merge");
LOG(INFO) << "test_merge";
h1 = grpc_histogram_create(0.05, 1e9);
grpc_histogram_add(h1, 2.5);

@ -28,6 +28,7 @@
#include <utility>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
@ -35,7 +36,6 @@
#include <grpc/grpc.h>
#include <grpc/grpc_security.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>
@ -154,12 +154,11 @@ static void got_port_from_server(void* arg, grpc_error_handle error) {
if (!error.ok()) {
failed = 1;
gpr_log(GPR_DEBUG, "failed port pick from server: retrying [%s]",
grpc_core::StatusToString(error).c_str());
VLOG(2) << "failed port pick from server: retrying ["
<< grpc_core::StatusToString(error) << "]";
} else if (response->status != 200) {
failed = 1;
gpr_log(GPR_DEBUG, "failed port pick from server: status=%d",
response->status);
VLOG(2) << "failed port pick from server: status=" << response->status;
}
if (failed) {

@ -20,16 +20,15 @@
#include <string>
#include "absl/log/log.h"
#include "absl/strings/match.h"
#include "gtest/gtest.h"
#include <grpc/support/log.h>
#include "test/core/test_util/test_config.h"
TEST(StackTracerTest, Basic) {
std::string stack_trace = grpc_core::testing::GetCurrentStackTrace();
gpr_log(GPR_INFO, "stack_trace=%s", stack_trace.c_str());
LOG(INFO) << "stack_trace=" << stack_trace;
#if !defined(NDEBUG) && !defined(GPR_MUSL_LIBC_COMPAT)
EXPECT_TRUE(absl::StrContains(stack_trace, "Basic"));
#endif

@ -22,13 +22,13 @@
#include <string>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "absl/types/variant.h"
#include <grpc/grpc.h>
#include <grpc/support/json.h>
#include <grpc/support/log.h>
#include "src/core/lib/address_utils/parse_address.h"
#include "src/core/lib/channel/channel_args.h"
@ -411,8 +411,8 @@ class FixedAddressLoadBalancingPolicy : public ForwardingLoadBalancingPolicy {
absl::Status UpdateLocked(UpdateArgs args) override {
auto* config = static_cast<FixedAddressConfig*>(args.config.get());
gpr_log(GPR_INFO, "%s: update URI: %s", kFixedAddressLbPolicyName,
config->address().c_str());
LOG(INFO) << kFixedAddressLbPolicyName
<< ": update URI: " << config->address();
auto uri = URI::Parse(config->address());
args.config.reset();
EndpointAddressesList addresses;
@ -421,9 +421,8 @@ class FixedAddressLoadBalancingPolicy : public ForwardingLoadBalancingPolicy {
CHECK(grpc_parse_uri(*uri, &address));
addresses.emplace_back(address, ChannelArgs());
} else {
gpr_log(GPR_ERROR,
"%s: could not parse URI (%s), using empty address list",
kFixedAddressLbPolicyName, uri.status().ToString().c_str());
LOG(ERROR) << kFixedAddressLbPolicyName << ": could not parse URI ("
<< uri.status().ToString() << "), using empty address list";
args.resolution_note = "no address in fixed_address_lb policy";
}
args.addresses =

@ -24,10 +24,10 @@
#include <algorithm>
#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/sync.h>
#include <grpc/support/time.h>
@ -91,7 +91,7 @@ void test_tcp_server_start(test_tcp_server* server, int port) {
CHECK(port_added == port);
grpc_tcp_server_start(server->tcp_server, &server->pollset);
gpr_log(GPR_INFO, "test tcp server listening on 0.0.0.0:%d", port);
LOG(INFO) << "test tcp server listening on 0.0.0.0:" << port;
}
void test_tcp_server_poll(test_tcp_server* server, int milliseconds) {

@ -19,6 +19,7 @@
#include <utility>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include "absl/time/time.h"
#include "gmock/gmock.h"
@ -98,8 +99,7 @@ class ChaoticGoodServerTest : public ::testing::Test {
protected:
static void OnConnectingFinished(void* arg, grpc_error_handle error) {
gpr_log(GPR_ERROR, "OnConnectingFinished: %p %s", arg,
error.ToString().c_str());
LOG(ERROR) << "OnConnectingFinished: " << arg << " " << error.ToString();
ChaoticGoodServerTest* test = static_cast<ChaoticGoodServerTest*>(arg);
test->connecting_successful_ = error.ok();
test->connect_finished_.Notify();

@ -19,11 +19,11 @@
#include <memory>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/random/bit_gen_ref.h"
#include "absl/status/statusor.h"
#include <grpc/event_engine/memory_allocator.h>
#include <grpc/support/log.h>
#include "src/core/ext/transport/chaotic_good/frame.h"
#include "src/core/ext/transport/chaotic_good/frame_header.h"
@ -63,8 +63,7 @@ void AssertRoundTrips(const T& input, FrameType expected_frame_type) {
auto header = FrameHeader::Parse(header_bytes);
if (!header.ok()) {
if (!squelch) {
gpr_log(GPR_ERROR, "Failed to parse header: %s",
header.status().ToString().c_str());
LOG(ERROR) << "Failed to parse header: " << header.status().ToString();
}
Crash("Failed to parse header");
}
@ -89,7 +88,7 @@ void FinishParseAndChecks(const FrameHeader& header, BufferPair buffers) {
absl::BitGenRef(bitgen), GetContext<Arena>(),
std::move(buffers), FuzzerFrameLimits());
if (!deser.ok()) return;
gpr_log(GPR_INFO, "Read frame: %s", parsed.ToString().c_str());
LOG(INFO) << "Read frame: " << parsed.ToString();
AssertRoundTrips(parsed, header.type);
}
@ -101,7 +100,7 @@ void Run(const frame_fuzzer::Test& test) {
auto r = FrameHeader::Parse(control_data);
if (!r.ok()) return;
if (test.data().size() != r->message_length) return;
gpr_log(GPR_INFO, "Read frame header: %s", r->ToString().c_str());
LOG(INFO) << "Read frame header: " << r->ToString();
control_data += 24;
control_size -= 24;
MemoryAllocator memory_allocator = MemoryAllocator(

@ -22,10 +22,10 @@
#include <memory>
#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
#include "src/core/lib/iomgr/exec_ctx.h"
@ -40,8 +40,8 @@ static void expect_slice_eq(grpc_slice expected, grpc_slice slice,
if (!grpc_slice_eq(slice, expected)) {
char* hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
char* he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs,
he);
LOG(ERROR) << "FAILED:" << line << ": " << debug << "\ngot: " << hs
<< "\nwant: " << he;
gpr_free(hs);
gpr_free(he);
all_ok = 0;

@ -24,9 +24,10 @@
#include <gtest/gtest.h>
#include "absl/log/log.h"
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/util/string.h"
@ -39,8 +40,8 @@ static void expect_slice_eq(grpc_slice expected, grpc_slice slice,
if (!grpc_slice_eq(slice, expected)) {
char* hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
char* he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs,
he);
LOG(ERROR) << "FAILED:" << line << ": " << debug << "\ngot: " << hs
<< "\nwant: " << he;
gpr_free(hs);
gpr_free(he);
all_ok = 0;
@ -79,8 +80,8 @@ static void expect_combined_equiv(const char* s, size_t len, int line) {
char* t = grpc_dump_slice(input, GPR_DUMP_HEX | GPR_DUMP_ASCII);
char* e = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII);
char* g = grpc_dump_slice(got, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, "FAILED:%d:\ntest: %s\ngot: %s\nwant: %s", line, t, g,
e);
LOG(ERROR) << "FAILED:" << line << ":\ntest: " << t << "\ngot: " << g
<< "\nwant: " << e;
gpr_free(t);
gpr_free(e);
gpr_free(g);
@ -97,8 +98,8 @@ static void expect_combined_equiv(const char* s, size_t len, int line) {
static void expect_binary_header(const char* hdr, int binary) {
if (grpc_is_binary_header(grpc_slice_from_static_string(hdr)) != binary) {
gpr_log(GPR_ERROR, "FAILED: expected header '%s' to be %s", hdr,
binary ? "binary" : "not binary");
LOG(ERROR) << "FAILED: expected header '" << hdr << "' to be "
<< (binary ? "binary" : "not binary");
all_ok = 0;
}
}

@ -18,6 +18,7 @@
#include <gtest/gtest.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/port_platform.h>
@ -68,8 +69,8 @@ class MetadataTest : public ::testing::TestWithParam<Param> {
TEST_P(MetadataTest, MetadataSize) {
const bool intern_key = GetParam().intern_key;
const bool intern_value = GetParam().intern_value;
gpr_log(GPR_INFO, "test_mdelem_size: intern_key=%d intern_value=%d",
intern_key, intern_value);
LOG(INFO) << "test_mdelem_size: intern_key=" << intern_key
<< " intern_value=" << intern_value;
grpc_init();
ExecCtx exec_ctx;

@ -19,6 +19,7 @@
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include "gtest/gtest.h"
@ -30,7 +31,6 @@
#include <grpc/impl/propagation_bits.h>
#include <grpc/slice.h>
#include <grpc/status.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/time.h>
@ -199,19 +199,15 @@ class TransportCounter {
grpc_core::MutexLock lock(&mu_);
++num_created_;
++num_live_;
gpr_log(GPR_INFO,
"TransportCounter num_created_=%ld num_live_=%" PRId64
" InitCallback",
num_created_, num_live_);
LOG(INFO) << "TransportCounter num_created_=" << num_created_
<< " num_live_=" << num_live_ << " InitCallback";
}
void DestructCallback() {
grpc_core::MutexLock lock(&mu_);
--num_live_;
gpr_log(GPR_INFO,
"TransportCounter num_created_=%ld num_live_=%" PRId64
" DestructCallback",
num_created_, num_live_);
LOG(INFO) << "TransportCounter num_created_=" << num_created_
<< " num_live_=" << num_live_ << " DestructCallback";
}
int64_t num_live() {
@ -237,9 +233,8 @@ void CounterInitCallback() { g_transport_counter->InitCallback(); }
void CounterDestructCallback() { g_transport_counter->DestructCallback(); }
void EnsureConnectionsArentLeaked(grpc_completion_queue* cq) {
gpr_log(
GPR_INFO,
"The channel has been destroyed, wait for it to shut down and close...");
LOG(INFO) << "The channel has been destroyed, wait for it to shut down and "
"close...";
// Do a quick initial poll to try to exit the test early if things have
// already cleaned up.
CHECK(grpc_completion_queue_next(
@ -249,30 +244,26 @@ void EnsureConnectionsArentLeaked(grpc_completion_queue* cq) {
nullptr)
.type == GRPC_QUEUE_TIMEOUT);
if (g_transport_counter->num_created() < 2) {
gpr_log(GPR_ERROR,
"g_transport_counter->num_created() == %ld. This means that "
"g_transport_counter isn't working and this test is broken. At "
"least a couple of transport objects should have been created.",
g_transport_counter->num_created());
LOG(ERROR) << "g_transport_counter->num_created() == "
<< g_transport_counter->num_created()
<< ". This means that g_transport_counter isn't working and "
"this test is broken. At least a couple of transport objects "
"should have been created.";
CHECK(0);
}
gpr_timespec overall_deadline = grpc_timeout_seconds_to_deadline(120);
for (;;) {
// Note: the main goal of this test is to try to repro a chttp2 stream leak,
// which also holds on to transports objects.
// Note: the main goal of this test is to try to repro a chttp2 stream
// leak, which also holds on to transports objects.
int64_t live_transports = g_transport_counter->num_live();
if (live_transports == 0) return;
if (gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), overall_deadline) > 0) {
gpr_log(GPR_INFO,
"g_transport_counter->num_live() never returned 0. "
"It's likely this test has triggered a connection leak.");
LOG(INFO) << "g_transport_counter->num_live() never returned 0. "
"It's likely this test has triggered a connection leak.";
CHECK(0);
}
gpr_log(GPR_INFO,
"g_transport_counter->num_live() returned %" PRId64
", keep waiting "
"until it reaches 0",
live_transports);
LOG(INFO) << "g_transport_counter->num_live() returned " << live_transports
<< ", keep waiting until it reaches 0";
CHECK(grpc_completion_queue_next(
cq,
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),

@ -20,10 +20,11 @@
#include <memory>
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include "gtest/gtest.h"
#include <grpc/slice.h>
#include <grpc/support/log.h>
#include "test/core/test_util/test_config.h"
@ -34,7 +35,7 @@ static void test_varint(uint32_t value, uint8_t prefix_or,
grpc_slice expect =
grpc_slice_from_copied_buffer(expect_bytes, expect_length);
grpc_slice slice;
gpr_log(GPR_DEBUG, "Test: 0x%08x", value);
VLOG(2) << absl::StrFormat("Test: 0x%08x", value);
ASSERT_EQ(w.length(), expect_length);
slice = grpc_slice_malloc(w.length());
w.Write(prefix_or, GRPC_SLICE_START_PTR(slice));

@ -20,6 +20,7 @@
#include <queue>
#include "absl/functional/any_invocable.h"
#include "absl/log/log.h"
#include "absl/random/bit_gen_ref.h"
#include "absl/strings/string_view.h"
#include "gmock/gmock.h"
@ -88,11 +89,9 @@ class ActionState {
State Get() const { return state_; }
void Set(State state, SourceLocation whence = {}) {
gpr_log(GPR_INFO, "%s",
absl::StrCat(StateString(state), " ", name(), " [", step(), "] ",
file(), ":", line(), " @ ", whence.file(), ":",
whence.line())
.c_str());
LOG(INFO) << StateString(state) << " " << name() << " [" << step() << "] "
<< file() << ":" << line() << " @ " << whence.file() << ":"
<< whence.line();
state_ = state;
}
const NameAndLocation& name_and_location() const {

@ -19,8 +19,8 @@
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpcpp/impl/service_type.h>
#include <grpcpp/server_builder.h>
@ -40,8 +40,7 @@ static void RunFakeHandshakerServer(const std::string& server_address,
grpc::ServerBuilder builder;
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
builder.RegisterService(service.get());
gpr_log(GPR_INFO, "Fake handshaker server listening on %s",
server_address.c_str());
LOG(INFO) << "Fake handshaker server listening on " << server_address;
std::unique_ptr<grpc::Server> server = builder.BuildAndStart();
server->Wait();
}

@ -25,10 +25,10 @@
#include <gtest/gtest.h>
#include <openssl/crypto.h>
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/gprpp/crash.h"
@ -316,7 +316,7 @@ TEST(TransportSecurityTest, TestPeerMatchesName) {
tsi_peer peer = peer_from_cert_name_test_entry(entry);
int result = tsi_ssl_peer_matches_name(&peer, entry->host_name);
if (result != entry->expected) {
gpr_log(GPR_ERROR, "%s", cert_name_test_entry_to_string(entry).c_str());
LOG(ERROR) << cert_name_test_entry_to_string(entry);
ASSERT_TRUE(0); // Unexpected result.
}
tsi_peer_destruct(&peer);

@ -18,19 +18,16 @@
#include "src/core/lib/gprpp/env.h"
#include "absl/log/log.h"
#include "gtest/gtest.h"
#include <grpc/support/log.h>
#include "test/core/test_util/test_config.h"
#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
TEST(EnvTest, SetenvGetenv) {
const char* name = "FOO";
const char* value = "BAR";
LOG_TEST_NAME("test_setenv_getenv");
LOG(INFO) << "test_setenv_getenv";
grpc_core::SetEnv(name, value);
auto retrieved_value = grpc_core::GetEnv(name);
@ -41,7 +38,7 @@ TEST(EnvTest, Unsetenv) {
const char* name = "FOO";
const char* value = "BAR";
LOG_TEST_NAME("test_unsetenv");
LOG(INFO) << "test_unsetenv";
grpc_core::SetEnv(name, value);
grpc_core::UnsetEnv(name);

@ -24,9 +24,9 @@
#include <utility>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/event_engine/default_event_engine.h"
@ -50,9 +50,8 @@ FakeXdsTransportFactory::FakeStreamingCall::~FakeStreamingCall() {
MutexLock lock(&mu_);
if (transport_->abort_on_undrained_messages()) {
for (const auto& message : from_client_messages_) {
gpr_log(GPR_ERROR, "[%s] %p From client message left in queue: %s",
transport_->server()->server_uri().c_str(), this,
message.c_str());
LOG(ERROR) << "[" << transport_->server()->server_uri() << "] " << this
<< " From client message left in queue: " << message;
}
CHECK(from_client_messages_.empty());
}

Loading…
Cancel
Save