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

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

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36800 from tanvi-jagtap:src_core_lib cc0411e99d
PiperOrigin-RevId: 642109824
pull/36870/head
Tanvi Jagtap 6 months ago committed by Copybara-Service
parent 03e91b6811
commit e4b7d46f43
  1. 28
      src/core/lib/channel/channel_args.cc
  2. 2
      src/core/lib/channel/promise_based_filter.h
  3. 3
      src/core/lib/compression/message_compress.cc
  4. 5
      src/core/lib/gprpp/crash.cc
  5. 58
      src/core/lib/gprpp/dual_ref_counted.h
  6. 7
      src/core/lib/gprpp/posix/stat.cc
  7. 14
      src/core/lib/gprpp/posix/thd.cc
  8. 43
      src/core/lib/gprpp/ref_counted.h
  9. 7
      src/core/lib/gprpp/time.cc
  10. 1
      src/core/lib/gprpp/time.h
  11. 7
      src/core/lib/gprpp/validation_errors.cc
  12. 7
      src/core/lib/gprpp/windows/stat.cc
  13. 19
      src/core/lib/security/authorization/cel_authorization_engine.cc
  14. 11
      src/core/lib/security/authorization/evaluate_args.cc
  15. 6
      src/core/lib/security/authorization/matchers.cc
  16. 5
      src/core/lib/security/certificate_provider/certificate_provider_registry.cc
  17. 5
      src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc
  18. 10
      src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc
  19. 6
      src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc
  20. 10
      src/core/lib/security/credentials/credentials.cc
  21. 12
      src/core/lib/security/credentials/external/external_account_credentials.cc
  22. 6
      src/core/lib/security/credentials/google_default/credentials_generic.cc
  23. 5
      src/core/lib/security/credentials/google_default/google_default_credentials.cc
  24. 6
      src/core/lib/security/credentials/jwt/json_token.cc
  25. 36
      src/core/lib/security/credentials/jwt/jwt_verifier.cc
  26. 27
      src/core/lib/security/credentials/ssl/ssl_credentials.cc
  27. 51
      src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc
  28. 5
      src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc
  29. 8
      src/core/lib/security/credentials/tls/grpc_tls_crl_provider.cc
  30. 19
      src/core/lib/security/credentials/tls/tls_credentials.cc
  31. 8
      src/core/lib/security/credentials/tls/tls_utils.cc
  32. 29
      src/core/lib/security/security_connector/alts/alts_security_connector.cc
  33. 23
      src/core/lib/security/security_connector/fake/fake_security_connector.cc
  34. 4
      src/core/lib/security/security_connector/load_system_roots_supported.cc
  35. 20
      src/core/lib/security/security_connector/local/local_security_connector.cc
  36. 33
      src/core/lib/security/security_connector/ssl/ssl_security_connector.cc
  37. 23
      src/core/lib/security/security_connector/ssl_utils.cc
  38. 64
      src/core/lib/security/security_connector/tls/tls_security_connector.cc
  39. 12
      src/core/util/http_client/httpcli_security_connector.cc

@ -29,6 +29,7 @@
#include <vector> #include <vector>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -36,7 +37,6 @@
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -264,8 +264,7 @@ absl::optional<bool> ChannelArgs::GetBool(absl::string_view name) const {
if (v == nullptr) return absl::nullopt; if (v == nullptr) return absl::nullopt;
auto i = v->GetIfInt(); auto i = v->GetIfInt();
if (!i.has_value()) { if (!i.has_value()) {
gpr_log(GPR_ERROR, "%s ignored: it must be an integer", LOG(ERROR) << name << " ignored: it must be an integer";
std::string(name).c_str());
return absl::nullopt; return absl::nullopt;
} }
switch (*i) { switch (*i) {
@ -274,8 +273,8 @@ absl::optional<bool> ChannelArgs::GetBool(absl::string_view name) const {
case 1: case 1:
return true; return true;
default: default:
gpr_log(GPR_ERROR, "%s treated as bool but set to %d (assuming true)", LOG(ERROR) << name << " treated as bool but set to " << *i
std::string(name).c_str(), *i); << " (assuming true)";
return true; return true;
} }
} }
@ -557,17 +556,15 @@ int grpc_channel_arg_get_integer(const grpc_arg* arg,
const grpc_integer_options options) { const grpc_integer_options options) {
if (arg == nullptr) return options.default_value; if (arg == nullptr) return options.default_value;
if (arg->type != GRPC_ARG_INTEGER) { if (arg->type != GRPC_ARG_INTEGER) {
gpr_log(GPR_ERROR, "%s ignored: it must be an integer", arg->key); LOG(ERROR) << arg->key << " ignored: it must be an integer";
return options.default_value; return options.default_value;
} }
if (arg->value.integer < options.min_value) { if (arg->value.integer < options.min_value) {
gpr_log(GPR_ERROR, "%s ignored: it must be >= %d", arg->key, LOG(ERROR) << arg->key << " ignored: it must be >= " << options.min_value;
options.min_value);
return options.default_value; return options.default_value;
} }
if (arg->value.integer > options.max_value) { if (arg->value.integer > options.max_value) {
gpr_log(GPR_ERROR, "%s ignored: it must be <= %d", arg->key, LOG(ERROR) << arg->key << " ignored: it must be <= " << options.max_value;
options.max_value);
return options.default_value; return options.default_value;
} }
return arg->value.integer; return arg->value.integer;
@ -583,7 +580,7 @@ int grpc_channel_args_find_integer(const grpc_channel_args* args,
char* grpc_channel_arg_get_string(const grpc_arg* arg) { char* grpc_channel_arg_get_string(const grpc_arg* arg) {
if (arg == nullptr) return nullptr; if (arg == nullptr) return nullptr;
if (arg->type != GRPC_ARG_STRING) { if (arg->type != GRPC_ARG_STRING) {
gpr_log(GPR_ERROR, "%s ignored: it must be an string", arg->key); LOG(ERROR) << arg->key << " ignored: it must be an string";
return nullptr; return nullptr;
} }
return arg->value.string; return arg->value.string;
@ -598,7 +595,7 @@ char* grpc_channel_args_find_string(const grpc_channel_args* args,
bool grpc_channel_arg_get_bool(const grpc_arg* arg, bool default_value) { bool grpc_channel_arg_get_bool(const grpc_arg* arg, bool default_value) {
if (arg == nullptr) return default_value; if (arg == nullptr) return default_value;
if (arg->type != GRPC_ARG_INTEGER) { if (arg->type != GRPC_ARG_INTEGER) {
gpr_log(GPR_ERROR, "%s ignored: it must be an integer", arg->key); LOG(ERROR) << arg->key << " ignored: it must be an integer";
return default_value; return default_value;
} }
switch (arg->value.integer) { switch (arg->value.integer) {
@ -607,8 +604,8 @@ bool grpc_channel_arg_get_bool(const grpc_arg* arg, bool default_value) {
case 1: case 1:
return true; return true;
default: default:
gpr_log(GPR_ERROR, "%s treated as bool but set to %d (assuming true)", LOG(ERROR) << arg->key << " treated as bool but set to "
arg->key, arg->value.integer); << arg->value.integer << " (assuming true)";
return true; return true;
} }
} }
@ -667,8 +664,7 @@ ChannelArgs ChannelArgsBuiltinPrecondition(const grpc_channel_args* src) {
if (key == GRPC_ARG_PRIMARY_USER_AGENT_STRING || if (key == GRPC_ARG_PRIMARY_USER_AGENT_STRING ||
key == GRPC_ARG_SECONDARY_USER_AGENT_STRING) { key == GRPC_ARG_SECONDARY_USER_AGENT_STRING) {
if (src->args[i].type != GRPC_ARG_STRING) { if (src->args[i].type != GRPC_ARG_STRING) {
gpr_log(GPR_ERROR, "Channel argument '%s' should be a string", LOG(ERROR) << "Channel argument '" << key << "' should be a string";
std::string(key).c_str());
} else { } else {
concatenated_values[key].push_back(src->args[i].value.string); concatenated_values[key].push_back(src->args[i].value.string);
} }

@ -32,6 +32,7 @@
#include "absl/container/inlined_vector.h" #include "absl/container/inlined_vector.h"
#include "absl/functional/function_ref.h" #include "absl/functional/function_ref.h"
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/meta/type_traits.h" #include "absl/meta/type_traits.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
@ -39,7 +40,6 @@
#include <grpc/event_engine/event_engine.h> #include <grpc/event_engine/event_engine.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/channel/call_finalization.h" #include "src/core/lib/channel/call_finalization.h"

@ -28,7 +28,6 @@
#include <grpc/slice_buffer.h> #include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice.h"
@ -63,7 +62,7 @@ static int zlib_body(z_stream* zs, grpc_slice_buffer* input,
} }
r = flate(zs, flush); r = flate(zs, flush);
if (r < 0 && r != Z_BUF_ERROR /* not fatal */) { if (r < 0 && r != Z_BUF_ERROR /* not fatal */) {
gpr_log(GPR_INFO, "zlib error (%d)", r); LOG(INFO) << "zlib error (" << r << ")";
goto error; goto error;
} }
} while (zs->avail_out == 0); } while (zs->avail_out == 0);

@ -19,16 +19,15 @@
#include <string> #include <string>
#include "absl/log/log.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
namespace grpc_core { namespace grpc_core {
void Crash(absl::string_view message, SourceLocation location) { void Crash(absl::string_view message, SourceLocation location) {
gpr_log(location.file(), location.line(), GPR_LOG_SEVERITY_ERROR, "%s", LOG(ERROR).AtLocation(location.file(), location.line()) << message;
std::string(message).c_str());
abort(); abort();
} }

@ -21,8 +21,8 @@
#include <cstdint> #include <cstdint>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/debug_location.h"
@ -93,8 +93,9 @@ class DualRefCounted : public Impl {
#ifndef NDEBUG #ifndef NDEBUG
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair); const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p unref %d -> %d, weak_ref %d -> %d", trace_, this, LOG(INFO) << trace_ << ":" << this << " unref " << strong_refs << " -> "
strong_refs, strong_refs - 1, weak_refs, weak_refs + 1); << strong_refs - 1 << ", weak_ref " << weak_refs << " -> "
<< weak_refs + 1;
} }
CHECK_GT(strong_refs, 0u); CHECK_GT(strong_refs, 0u);
#endif #endif
@ -111,9 +112,10 @@ class DualRefCounted : public Impl {
#ifndef NDEBUG #ifndef NDEBUG
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair); const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p %s:%d unref %d -> %d, weak_ref %d -> %d) %s", LOG(INFO) << trace_ << ":" << this << " " << location.file() << ":"
trace_, this, location.file(), location.line(), strong_refs, << location.line() << " unref " << strong_refs << " -> "
strong_refs - 1, weak_refs, weak_refs + 1, reason); << strong_refs - 1 << ", weak_ref " << weak_refs << " -> "
<< weak_refs + 1 << ") " << reason;
} }
CHECK_GT(strong_refs, 0u); CHECK_GT(strong_refs, 0u);
#else #else
@ -135,8 +137,9 @@ class DualRefCounted : public Impl {
#ifndef NDEBUG #ifndef NDEBUG
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair); const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p ref_if_non_zero %d -> %d (weak_refs=%d)", LOG(INFO) << trace_ << ":" << this << " ref_if_non_zero " << strong_refs
trace_, this, strong_refs, strong_refs + 1, weak_refs); << " -> " << strong_refs + 1 << " (weak_refs=" << weak_refs
<< ")";
} }
#endif #endif
if (strong_refs == 0) return nullptr; if (strong_refs == 0) return nullptr;
@ -153,10 +156,10 @@ class DualRefCounted : public Impl {
#ifndef NDEBUG #ifndef NDEBUG
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair); const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, LOG(INFO) << trace_ << ":" << this << " " << location.file() << ":"
"%s:%p %s:%d ref_if_non_zero %d -> %d (weak_refs=%d) %s", << location.line() << " ref_if_non_zero " << strong_refs
trace_, this, location.file(), location.line(), strong_refs, << " -> " << strong_refs + 1 << " (weak_refs=" << weak_refs
strong_refs + 1, weak_refs, reason); << ") " << reason;
} }
#else #else
// Avoid unused-parameter warnings for debug-only parameters // Avoid unused-parameter warnings for debug-only parameters
@ -211,8 +214,8 @@ class DualRefCounted : public Impl {
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair); const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
const uint32_t strong_refs = GetStrongRefs(prev_ref_pair); const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
if (trace != nullptr) { if (trace != nullptr) {
gpr_log(GPR_INFO, "%s:%p weak_unref %d -> %d (refs=%d)", trace, this, LOG(INFO) << trace << ":" << this << " weak_unref " << weak_refs << " -> "
weak_refs, weak_refs - 1, strong_refs); << weak_refs - 1 << " (refs=" << strong_refs << ")";
} }
CHECK_GT(weak_refs, 0u); CHECK_GT(weak_refs, 0u);
#endif #endif
@ -233,9 +236,9 @@ class DualRefCounted : public Impl {
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair); const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
const uint32_t strong_refs = GetStrongRefs(prev_ref_pair); const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
if (trace != nullptr) { if (trace != nullptr) {
gpr_log(GPR_INFO, "%s:%p %s:%d weak_unref %d -> %d (refs=%d) %s", trace, LOG(INFO) << trace << ":" << this << " " << location.file() << ":"
this, location.file(), location.line(), weak_refs, weak_refs - 1, << location.line() << " weak_unref " << weak_refs << " -> "
strong_refs, reason); << weak_refs - 1 << " (refs=" << strong_refs << ") " << reason;
} }
CHECK_GT(weak_refs, 0u); CHECK_GT(weak_refs, 0u);
#else #else
@ -298,8 +301,8 @@ class DualRefCounted : public Impl {
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair); const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
CHECK_NE(strong_refs, 0u); CHECK_NE(strong_refs, 0u);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p ref %d -> %d; (weak_refs=%d)", trace_, this, LOG(INFO) << trace_ << ":" << this << " ref " << strong_refs << " -> "
strong_refs, strong_refs + 1, weak_refs); << strong_refs + 1 << "; (weak_refs=" << weak_refs << ")";
} }
#else #else
refs_.fetch_add(MakeRefPair(1, 0), std::memory_order_relaxed); refs_.fetch_add(MakeRefPair(1, 0), std::memory_order_relaxed);
@ -313,9 +316,10 @@ class DualRefCounted : public Impl {
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair); const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
CHECK_NE(strong_refs, 0u); CHECK_NE(strong_refs, 0u);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p %s:%d ref %d -> %d (weak_refs=%d) %s", trace_, LOG(INFO) << trace_ << ":" << this << " " << location.file() << ":"
this, location.file(), location.line(), strong_refs, << location.line() << " ref " << strong_refs << " -> "
strong_refs + 1, weak_refs, reason); << strong_refs + 1 << " (weak_refs=" << weak_refs << ") "
<< reason;
} }
#else #else
// Use conditionally-important parameters // Use conditionally-important parameters
@ -332,8 +336,8 @@ class DualRefCounted : public Impl {
const uint32_t strong_refs = GetStrongRefs(prev_ref_pair); const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair); const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p weak_ref %d -> %d; (refs=%d)", trace_, this, LOG(INFO) << trace_ << ":" << this << " weak_ref " << weak_refs << " -> "
weak_refs, weak_refs + 1, strong_refs); << weak_refs + 1 << "; (refs=" << strong_refs << ")";
} }
if (strong_refs == 0) CHECK_NE(weak_refs, 0u); if (strong_refs == 0) CHECK_NE(weak_refs, 0u);
#else #else
@ -348,9 +352,9 @@ class DualRefCounted : public Impl {
const uint32_t strong_refs = GetStrongRefs(prev_ref_pair); const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
const uint32_t weak_refs = GetWeakRefs(prev_ref_pair); const uint32_t weak_refs = GetWeakRefs(prev_ref_pair);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p %s:%d weak_ref %d -> %d (refs=%d) %s", trace_, LOG(INFO) << trace_ << ":" << this << " " << location.file() << ":"
this, location.file(), location.line(), weak_refs, weak_refs + 1, << location.line() << " weak_ref " << weak_refs << " -> "
strong_refs, reason); << weak_refs + 1 << " (refs=" << strong_refs << ") " << reason;
} }
if (strong_refs == 0) CHECK_NE(weak_refs, 0u); if (strong_refs == 0) CHECK_NE(weak_refs, 0u);
#else #else

@ -28,8 +28,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/stat.h" #include "src/core/lib/gprpp/stat.h"
#include "src/core/lib/gprpp/strerror.h" #include "src/core/lib/gprpp/strerror.h"
@ -42,8 +41,8 @@ absl::Status GetFileModificationTime(const char* filename, time_t* timestamp) {
struct stat buf; struct stat buf;
if (stat(filename, &buf) != 0) { if (stat(filename, &buf) != 0) {
std::string error_msg = StrError(errno); std::string error_msg = StrError(errno);
gpr_log(GPR_ERROR, "stat failed for filename %s with error %s.", filename, LOG(ERROR) << "stat failed for filename " << filename << " with error "
error_msg.c_str()); << error_msg;
return absl::Status(absl::StatusCode::kInternal, error_msg); return absl::Status(absl::StatusCode::kInternal, error_msg);
} }
// Last file/directory modification time. // Last file/directory modification time.

@ -33,9 +33,8 @@
#include <unistd.h> #include <unistd.h>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h" // IWYU pragma: keep #include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/thd_id.h> #include <grpc/support/thd_id.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -158,8 +157,7 @@ class ThreadInternalsPosix : public internal::ThreadInternalsInterface {
CHECK_EQ(pthread_attr_destroy(&attr), 0); CHECK_EQ(pthread_attr_destroy(&attr), 0);
if (!(*success)) { if (!(*success)) {
gpr_log(GPR_ERROR, "pthread_create failed: %s", LOG(ERROR) << "pthread_create failed: " << StrError(pthread_create_err);
StrError(pthread_create_err).c_str());
// don't use gpr_free, as this was allocated using malloc (see above) // don't use gpr_free, as this was allocated using malloc (see above)
free(info); free(info);
if (options.tracked()) { if (options.tracked()) {
@ -199,8 +197,8 @@ class ThreadInternalsPosix : public internal::ThreadInternalsInterface {
void Thread::Signal(gpr_thd_id tid, int sig) { void Thread::Signal(gpr_thd_id tid, int sig) {
auto kill_err = pthread_kill((pthread_t)tid, sig); auto kill_err = pthread_kill((pthread_t)tid, sig);
if (kill_err != 0) { if (kill_err != 0) {
gpr_log(GPR_ERROR, "pthread_kill for tid %" PRIdPTR " failed: %s", tid, LOG(ERROR) << "pthread_kill for tid " << tid
StrError(kill_err).c_str()); << " failed: " << StrError(kill_err);
} }
} }
@ -208,8 +206,8 @@ void Thread::Signal(gpr_thd_id tid, int sig) {
void Thread::Kill(gpr_thd_id tid) { void Thread::Kill(gpr_thd_id tid) {
auto cancel_err = pthread_cancel((pthread_t)tid); auto cancel_err = pthread_cancel((pthread_t)tid);
if (cancel_err != 0) { if (cancel_err != 0) {
gpr_log(GPR_ERROR, "pthread_cancel for tid %" PRIdPTR " failed: %s", tid, LOG(ERROR) << "pthread_cancel for tid " << tid
StrError(cancel_err).c_str()); << " failed: " << StrError(cancel_err);
} }
} }
#else // GPR_ANDROID #else // GPR_ANDROID

@ -24,8 +24,8 @@
#include <cinttypes> #include <cinttypes>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/gprpp/atomic_utils.h" #include "src/core/lib/gprpp/atomic_utils.h"
@ -73,8 +73,8 @@ class RefCount {
#ifndef NDEBUG #ifndef NDEBUG
const Value prior = value_.fetch_add(n, std::memory_order_relaxed); const Value prior = value_.fetch_add(n, std::memory_order_relaxed);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p ref %" PRIdPTR " -> %" PRIdPTR, trace_, this, LOG(INFO) << trace_ << ":" << this << " ref " << prior << " -> "
prior, prior + n); << prior + n;
} }
#else #else
value_.fetch_add(n, std::memory_order_relaxed); value_.fetch_add(n, std::memory_order_relaxed);
@ -84,9 +84,9 @@ class RefCount {
#ifndef NDEBUG #ifndef NDEBUG
const Value prior = value_.fetch_add(n, std::memory_order_relaxed); const Value prior = value_.fetch_add(n, std::memory_order_relaxed);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s", LOG(INFO) << trace_ << ":" << this << " " << location.file() << ":"
trace_, this, location.file(), location.line(), prior, prior + n, << location.line() << " ref " << prior << " -> " << prior + n
reason); << " " << reason;
} }
#else #else
// Use conditionally-important parameters // Use conditionally-important parameters
@ -101,8 +101,8 @@ class RefCount {
#ifndef NDEBUG #ifndef NDEBUG
const Value prior = value_.fetch_add(1, std::memory_order_relaxed); const Value prior = value_.fetch_add(1, std::memory_order_relaxed);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p ref %" PRIdPTR " -> %" PRIdPTR, trace_, this, LOG(INFO) << trace_ << ":" << this << " ref " << prior << " -> "
prior, prior + 1); << prior + 1;
} }
assert(prior > 0); assert(prior > 0);
#else #else
@ -113,9 +113,9 @@ class RefCount {
#ifndef NDEBUG #ifndef NDEBUG
const Value prior = value_.fetch_add(1, std::memory_order_relaxed); const Value prior = value_.fetch_add(1, std::memory_order_relaxed);
if (trace_ != nullptr) { if (trace_ != nullptr) {
gpr_log(GPR_INFO, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s", LOG(INFO) << trace_ << ":" << this << " " << location.file() << ":"
trace_, this, location.file(), location.line(), prior, prior + 1, << location.line() << " ref " << prior << " -> " << prior + 1
reason); << " " << reason;
} }
assert(prior > 0); assert(prior > 0);
#else #else
@ -130,8 +130,8 @@ class RefCount {
#ifndef NDEBUG #ifndef NDEBUG
if (trace_ != nullptr) { if (trace_ != nullptr) {
const Value prior = get(); const Value prior = get();
gpr_log(GPR_INFO, "%s:%p ref_if_non_zero %" PRIdPTR " -> %" PRIdPTR, LOG(INFO) << trace_ << ":" << this << " ref_if_non_zero " << prior
trace_, this, prior, prior + 1); << " -> " << prior + 1;
} }
#endif #endif
return IncrementIfNonzero(&value_); return IncrementIfNonzero(&value_);
@ -140,10 +140,9 @@ class RefCount {
#ifndef NDEBUG #ifndef NDEBUG
if (trace_ != nullptr) { if (trace_ != nullptr) {
const Value prior = get(); const Value prior = get();
gpr_log(GPR_INFO, LOG(INFO) << trace_ << ":" << this << " " << location.file() << ":"
"%s:%p %s:%d ref_if_non_zero %" PRIdPTR " -> %" PRIdPTR " %s", << location.line() << " ref_if_non_zero " << prior << " -> "
trace_, this, location.file(), location.line(), prior, prior + 1, << prior + 1 << " " << reason;
reason);
} }
#endif #endif
// Avoid unused-parameter warnings for debug-only parameters // Avoid unused-parameter warnings for debug-only parameters
@ -163,8 +162,8 @@ class RefCount {
const Value prior = value_.fetch_sub(1, std::memory_order_acq_rel); const Value prior = value_.fetch_sub(1, std::memory_order_acq_rel);
#ifndef NDEBUG #ifndef NDEBUG
if (trace != nullptr) { if (trace != nullptr) {
gpr_log(GPR_INFO, "%s:%p unref %" PRIdPTR " -> %" PRIdPTR, trace, this, LOG(INFO) << trace << ":" << this << " unref " << prior << " -> "
prior, prior - 1); << prior - 1;
} }
DCHECK_GT(prior, 0); DCHECK_GT(prior, 0);
#endif #endif
@ -180,9 +179,9 @@ class RefCount {
const Value prior = value_.fetch_sub(1, std::memory_order_acq_rel); const Value prior = value_.fetch_sub(1, std::memory_order_acq_rel);
#ifndef NDEBUG #ifndef NDEBUG
if (trace != nullptr) { if (trace != nullptr) {
gpr_log(GPR_INFO, "%s:%p %s:%d unref %" PRIdPTR " -> %" PRIdPTR " %s", LOG(INFO) << trace << ":" << this << " " << location.file() << ":"
trace, this, location.file(), location.line(), prior, prior - 1, << location.line() << " unref " << prior << " -> " << prior - 1
reason); << " " << reason;
} }
DCHECK_GT(prior, 0); DCHECK_GT(prior, 0);
#else #else

@ -21,9 +21,9 @@
#include <utility> #include <utility>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -60,9 +60,8 @@ GPR_ATTRIBUTE_NOINLINE std::pair<int64_t, gpr_cycle_counter> InitTime() {
if (process_epoch_seconds > 1) { if (process_epoch_seconds > 1) {
break; break;
} }
gpr_log(GPR_INFO, LOG(INFO) << "gpr_now(GPR_CLOCK_MONOTONIC) returns a very small number: "
"gpr_now(GPR_CLOCK_MONOTONIC) returns a very small number: " "sleeping for 100ms";
"sleeping for 100ms");
gpr_sleep_until(gpr_time_add(now, gpr_time_from_millis(100, GPR_TIMESPAN))); gpr_sleep_until(gpr_time_add(now, gpr_time_from_millis(100, GPR_TIMESPAN)));
} }

@ -24,6 +24,7 @@
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include <grpc/event_engine/event_engine.h> #include <grpc/event_engine/event_engine.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>

@ -18,12 +18,12 @@
#include <utility> #include <utility>
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h" #include "absl/strings/str_join.h"
#include "absl/strings/strip.h" #include "absl/strings/strip.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
namespace grpc_core { namespace grpc_core {
@ -39,9 +39,8 @@ void ValidationErrors::PopField() { fields_.pop_back(); }
void ValidationErrors::AddError(absl::string_view error) { void ValidationErrors::AddError(absl::string_view error) {
auto key = absl::StrJoin(fields_, ""); auto key = absl::StrJoin(fields_, "");
if (field_errors_[key].size() >= max_error_count_) { if (field_errors_[key].size() >= max_error_count_) {
gpr_log(GPR_DEBUG, VLOG(2) << "Ignoring validation error: too many errors found ("
"Ignoring validation error: too many errors found (%" PRIuPTR ")", << max_error_count_ << ")";
max_error_count_);
return; return;
} }
field_errors_[key].emplace_back(error); field_errors_[key].emplace_back(error);

@ -23,8 +23,7 @@
#include <sys/types.h> #include <sys/types.h>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/stat.h" #include "src/core/lib/gprpp/stat.h"
@ -38,8 +37,8 @@ absl::Status GetFileModificationTime(const char* filename, time_t* timestamp) {
struct _stat buf; struct _stat buf;
if (_stat(filename, &buf) != 0) { if (_stat(filename, &buf) != 0) {
std::string error_msg = StrError(errno); std::string error_msg = StrError(errno);
gpr_log(GPR_ERROR, "_stat failed for filename %s with error %s.", filename, LOG(ERROR) << "_stat failed for filename " << filename << " with error "
error_msg.c_str()); << error_msg;
return absl::Status(absl::StatusCode::kInternal, error_msg); return absl::Status(absl::StatusCode::kInternal, error_msg);
} }
// Last file/directory modification time. // Last file/directory modification time.

@ -19,13 +19,13 @@
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
#include "absl/log/log.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "absl/types/span.h" #include "absl/types/span.h"
#include "upb/base/string_view.h" #include "upb/base/string_view.h"
#include "upb/message/map.h" #include "upb/message/map.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
namespace grpc_core { namespace grpc_core {
@ -50,16 +50,14 @@ std::unique_ptr<CelAuthorizationEngine>
CelAuthorizationEngine::CreateCelAuthorizationEngine( CelAuthorizationEngine::CreateCelAuthorizationEngine(
const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies) { const std::vector<envoy_config_rbac_v3_RBAC*>& rbac_policies) {
if (rbac_policies.empty() || rbac_policies.size() > 2) { if (rbac_policies.empty() || rbac_policies.size() > 2) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Invalid rbac policies vector. Must contain either one or "
"Invalid rbac policies vector. Must contain either one or two rbac " "two rbac policies.";
"policies.");
return nullptr; return nullptr;
} else if (rbac_policies.size() == 2 && } else if (rbac_policies.size() == 2 &&
(envoy_config_rbac_v3_RBAC_action(rbac_policies[0]) != kDeny || (envoy_config_rbac_v3_RBAC_action(rbac_policies[0]) != kDeny ||
envoy_config_rbac_v3_RBAC_action(rbac_policies[1]) != kAllow)) { envoy_config_rbac_v3_RBAC_action(rbac_policies[1]) != kAllow)) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Invalid rbac policies vector. Must contain one deny policy "
"Invalid rbac policies vector. Must contain one deny \ "and one allow policy, in that order.";
policy and one allow policy, in that order.");
return nullptr; return nullptr;
} else { } else {
return std::make_unique<CelAuthorizationEngine>(rbac_policies); return std::make_unique<CelAuthorizationEngine>(rbac_policies);
@ -175,10 +173,9 @@ std::unique_ptr<mock_cel::Activation> CelAuthorizationEngine::CreateActivation(
mock_cel::CelValue::CreateStringView(cert_server_name)); mock_cel::CelValue::CreateStringView(cert_server_name));
} }
} else { } else {
gpr_log(GPR_ERROR, LOG(ERROR) << "Error: Authorization engine does not support evaluating "
"Error: Authorization engine does not support evaluating " "attribute "
"attribute %s.", << elem;
elem.c_str());
} }
} }
return activation; return activation;

@ -23,7 +23,6 @@
#include "absl/strings/numbers.h" #include "absl/strings/numbers.h"
#include <grpc/grpc_security_constants.h> #include <grpc/grpc_security_constants.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/handshaker/endpoint_info/endpoint_info_handshaker.h" #include "src/core/handshaker/endpoint_info/endpoint_info_handshaker.h"
@ -48,19 +47,17 @@ EvaluateArgs::PerChannelArgs::Address ParseEndpointUri(
absl::string_view host_view; absl::string_view host_view;
absl::string_view port_view; absl::string_view port_view;
if (!SplitHostPort(uri->path(), &host_view, &port_view)) { if (!SplitHostPort(uri->path(), &host_view, &port_view)) {
gpr_log(GPR_DEBUG, "Failed to split %s into host and port.", VLOG(2) << "Failed to split " << uri->path() << " into host and port.";
uri->path().c_str());
return address; return address;
} }
if (!absl::SimpleAtoi(port_view, &address.port)) { if (!absl::SimpleAtoi(port_view, &address.port)) {
gpr_log(GPR_DEBUG, "Port %s is out of range or null.", VLOG(2) << "Port " << port_view << " is out of range or null.";
std::string(port_view).c_str());
} }
address.address_str = std::string(host_view); address.address_str = std::string(host_view);
auto resolved_address = StringToSockaddr(uri->path()); auto resolved_address = StringToSockaddr(uri->path());
if (!resolved_address.ok()) { if (!resolved_address.ok()) {
gpr_log(GPR_DEBUG, "Address \"%s\" is not IPv4/IPv6. Error: %s", VLOG(2) << "Address \"" << uri->path()
uri->path().c_str(), resolved_address.status().ToString().c_str()); << "\" is not IPv4/IPv6. Error: " << resolved_address.status();
memset(&address.address, 0, sizeof(address.address)); memset(&address.address, 0, sizeof(address.address));
} else { } else {
address.address = *resolved_address; address.address = *resolved_address;

@ -18,12 +18,12 @@
#include <string> #include <string>
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include <grpc/grpc_security_constants.h> #include <grpc/grpc_security_constants.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/address_utils/parse_address.h" #include "src/core/lib/address_utils/parse_address.h"
@ -157,8 +157,8 @@ IpAuthorizationMatcher::IpAuthorizationMatcher(Type type, Rbac::CidrRange range)
auto address = auto address =
StringToSockaddr(range.address_prefix, 0); // Port does not matter here. StringToSockaddr(range.address_prefix, 0); // Port does not matter here.
if (!address.ok()) { if (!address.ok()) {
gpr_log(GPR_DEBUG, "CidrRange address \"%s\" is not IPv4/IPv6. Error: %s", VLOG(2) << "CidrRange address \"" << range.address_prefix
range.address_prefix.c_str(), address.status().ToString().c_str()); << "\" is not IPv4/IPv6. Error: " << address.status();
memset(&subnet_address_, 0, sizeof(subnet_address_)); memset(&subnet_address_, 0, sizeof(subnet_address_));
return; return;
} }

@ -22,8 +22,8 @@
#include <utility> #include <utility>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
namespace grpc_core { namespace grpc_core {
@ -31,8 +31,7 @@ namespace grpc_core {
void CertificateProviderRegistry::Builder::RegisterCertificateProviderFactory( void CertificateProviderRegistry::Builder::RegisterCertificateProviderFactory(
std::unique_ptr<CertificateProviderFactory> factory) { std::unique_ptr<CertificateProviderFactory> factory) {
absl::string_view name = factory->name(); absl::string_view name = factory->name();
gpr_log(GPR_DEBUG, "registering certificate provider factory for \"%s\"", VLOG(2) << "registering certificate provider factory for \"" << name << "\"";
std::string(name).c_str());
CHECK(factories_.emplace(name, std::move(factory)).second); CHECK(factories_.emplace(name, std::move(factory)).second);
} }

@ -20,14 +20,13 @@
#if !defined(GPR_LINUX) && !defined(GPR_WINDOWS) #if !defined(GPR_LINUX) && !defined(GPR_WINDOWS)
#include <grpc/support/log.h> #include "absl/log/log.h"
#include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/security/credentials/alts/check_gcp_environment.h" #include "src/core/lib/security/credentials/alts/check_gcp_environment.h"
bool grpc_alts_is_running_on_gcp() { bool grpc_alts_is_running_on_gcp() {
gpr_log(GPR_INFO, LOG(INFO) << "ALTS: Platforms other than Linux and Windows are not supported";
"ALTS: Platforms other than Linux and Windows are not supported");
return false; return false;
} }

@ -16,9 +16,10 @@
// //
// //
#include "absl/log/log.h"
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -44,10 +45,9 @@ static target_service_account* target_service_account_create(
void grpc_alts_credentials_client_options_add_target_service_account( void grpc_alts_credentials_client_options_add_target_service_account(
grpc_alts_credentials_options* options, const char* service_account) { grpc_alts_credentials_options* options, const char* service_account) {
if (options == nullptr || service_account == nullptr) { if (options == nullptr || service_account == nullptr) {
gpr_log( LOG(ERROR)
GPR_ERROR, << "Invalid nullptr arguments to "
"Invalid nullptr arguments to " "grpc_alts_credentials_client_options_add_target_service_account()";
"grpc_alts_credentials_client_options_add_target_service_account()");
return; return;
} }
auto client_options = auto client_options =

@ -18,8 +18,9 @@
#include "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h" #include "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h"
#include "absl/log/log.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
grpc_alts_credentials_options* grpc_alts_credentials_options_copy( grpc_alts_credentials_options* grpc_alts_credentials_options_copy(
@ -29,8 +30,7 @@ grpc_alts_credentials_options* grpc_alts_credentials_options_copy(
return options->vtable->copy(options); return options->vtable->copy(options);
} }
// An error occurred. // An error occurred.
gpr_log(GPR_ERROR, LOG(ERROR) << "Invalid arguments to grpc_alts_credentials_options_copy()";
"Invalid arguments to grpc_alts_credentials_options_copy()");
return nullptr; return nullptr;
} }

@ -22,8 +22,8 @@
#include <string.h> #include <string.h>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
@ -75,8 +75,8 @@ grpc_channel_credentials* grpc_channel_credentials_from_arg(
const grpc_arg* arg) { const grpc_arg* arg) {
if (strcmp(arg->key, GRPC_ARG_CHANNEL_CREDENTIALS) != 0) return nullptr; if (strcmp(arg->key, GRPC_ARG_CHANNEL_CREDENTIALS) != 0) return nullptr;
if (arg->type != GRPC_ARG_POINTER) { if (arg->type != GRPC_ARG_POINTER) {
gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type, LOG(ERROR) << "Invalid type " << arg->type << " for arg "
GRPC_ARG_CHANNEL_CREDENTIALS); << GRPC_ARG_CHANNEL_CREDENTIALS;
return nullptr; return nullptr;
} }
return static_cast<grpc_channel_credentials*>(arg->value.pointer.p); return static_cast<grpc_channel_credentials*>(arg->value.pointer.p);
@ -141,8 +141,8 @@ grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials* c) {
grpc_server_credentials* grpc_server_credentials_from_arg(const grpc_arg* arg) { grpc_server_credentials* grpc_server_credentials_from_arg(const grpc_arg* arg) {
if (strcmp(arg->key, GRPC_SERVER_CREDENTIALS_ARG) != 0) return nullptr; if (strcmp(arg->key, GRPC_SERVER_CREDENTIALS_ARG) != 0) return nullptr;
if (arg->type != GRPC_ARG_POINTER) { if (arg->type != GRPC_ARG_POINTER) {
gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type, LOG(ERROR) << "Invalid type " << arg->type << " for arg "
GRPC_SERVER_CREDENTIALS_ARG); << GRPC_SERVER_CREDENTIALS_ARG;
return nullptr; return nullptr;
} }
return static_cast<grpc_server_credentials*>(arg->value.pointer.p); return static_cast<grpc_server_credentials*>(arg->value.pointer.p);

@ -23,6 +23,7 @@
#include <utility> #include <utility>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/escaping.h" #include "absl/strings/escaping.h"
@ -41,7 +42,6 @@
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/json.h> #include <grpc/support/json.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -588,9 +588,8 @@ grpc_call_credentials* grpc_external_account_credentials_create(
const char* json_string, const char* scopes_string) { const char* json_string, const char* scopes_string) {
auto json = grpc_core::JsonParse(json_string); auto json = grpc_core::JsonParse(json_string);
if (!json.ok()) { if (!json.ok()) {
gpr_log(GPR_ERROR, LOG(ERROR) << "External account credentials creation failed. Error: "
"External account credentials creation failed. Error: %s.", << json.status();
json.status().ToString().c_str());
return nullptr; return nullptr;
} }
std::vector<std::string> scopes = absl::StrSplit(scopes_string, ','); std::vector<std::string> scopes = absl::StrSplit(scopes_string, ',');
@ -599,9 +598,8 @@ grpc_call_credentials* grpc_external_account_credentials_create(
*json, std::move(scopes), &error) *json, std::move(scopes), &error)
.release(); .release();
if (!error.ok()) { if (!error.ok()) {
gpr_log(GPR_ERROR, LOG(ERROR) << "External account credentials creation failed. Error: "
"External account credentials creation failed. Error: %s.", << grpc_core::StatusToString(error);
grpc_core::StatusToString(error).c_str());
return nullptr; return nullptr;
} }
return creds; return creds;

@ -18,10 +18,10 @@
#include <string> #include <string>
#include "absl/log/log.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/gprpp/env.h" #include "src/core/lib/gprpp/env.h"
@ -31,8 +31,8 @@
std::string grpc_get_well_known_google_credentials_file_path_impl(void) { std::string grpc_get_well_known_google_credentials_file_path_impl(void) {
auto base = grpc_core::GetEnv(GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR); auto base = grpc_core::GetEnv(GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR);
if (!base.has_value()) { if (!base.has_value()) {
gpr_log(GPR_ERROR, "Could not get " GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR LOG(ERROR) << "Could not get " << GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR
" environment variable."); << " environment variable.";
return ""; return "";
} }
return absl::StrCat(*base, "/", GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX); return absl::StrCat(*base, "/", GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX);

@ -37,7 +37,6 @@
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/slice.h> #include <grpc/slice.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
@ -411,8 +410,8 @@ grpc_channel_credentials* grpc_google_default_credentials_create(
creds.get(), call_creds.get(), nullptr); creds.get(), call_creds.get(), nullptr);
CHECK_NE(result, nullptr); CHECK_NE(result, nullptr);
} else { } else {
gpr_log(GPR_ERROR, "Could not create google default credentials: %s", LOG(ERROR) << "Could not create google default credentials: "
grpc_core::StatusToString(error).c_str()); << grpc_core::StatusToString(error);
} }
return result; return result;
} }

@ -39,7 +39,6 @@
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/json.h> #include <grpc/support/json.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -141,8 +140,7 @@ grpc_auth_json_key grpc_auth_json_key_create_from_string(
Json json; Json json;
auto json_or = grpc_core::JsonParse(json_string); auto json_or = grpc_core::JsonParse(json_string);
if (!json_or.ok()) { if (!json_or.ok()) {
gpr_log(GPR_ERROR, "JSON key parsing error: %s", LOG(ERROR) << "JSON key parsing error: " << json_or.status();
json_or.status().ToString().c_str());
} else { } else {
json = std::move(*json_or); json = std::move(*json_or);
} }
@ -238,7 +236,7 @@ const EVP_MD* openssl_digest_from_algorithm(const char* algorithm) {
if (strcmp(algorithm, GRPC_JWT_RSA_SHA256_ALGORITHM) == 0) { if (strcmp(algorithm, GRPC_JWT_RSA_SHA256_ALGORITHM) == 0) {
return EVP_sha256(); return EVP_sha256();
} else { } else {
gpr_log(GPR_ERROR, "Unknown algorithm %s.", algorithm); LOG(ERROR) << "Unknown algorithm " << algorithm;
return nullptr; return nullptr;
} }
} }

@ -51,7 +51,6 @@
#include <grpc/slice.h> #include <grpc/slice.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/json.h> #include <grpc/support/json.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -120,8 +119,7 @@ static Json parse_json_part_from_jwt(const char* str, size_t len) {
} }
auto json = grpc_core::JsonParse(string); auto json = grpc_core::JsonParse(string);
if (!json.ok()) { if (!json.ok()) {
gpr_log(GPR_ERROR, "JSON parse error: %s", LOG(ERROR) << "JSON parse error: " << json.status();
json.status().ToString().c_str());
return Json(); // JSON null return Json(); // JSON null
} }
return std::move(*json); return std::move(*json);
@ -129,7 +127,7 @@ static Json parse_json_part_from_jwt(const char* str, size_t len) {
static const char* validate_string_field(const Json& json, const char* key) { static const char* validate_string_field(const Json& json, const char* key) {
if (json.type() != Json::Type::kString) { if (json.type() != Json::Type::kString) {
gpr_log(GPR_ERROR, "Invalid %s field", key); LOG(ERROR) << "Invalid " << key << " field";
return nullptr; return nullptr;
} }
return json.string().c_str(); return json.string().c_str();
@ -138,7 +136,7 @@ static const char* validate_string_field(const Json& json, const char* key) {
static gpr_timespec validate_time_field(const Json& json, const char* key) { static gpr_timespec validate_time_field(const Json& json, const char* key) {
gpr_timespec result = gpr_time_0(GPR_CLOCK_REALTIME); gpr_timespec result = gpr_time_0(GPR_CLOCK_REALTIME);
if (json.type() != Json::Type::kNumber) { if (json.type() != Json::Type::kNumber) {
gpr_log(GPR_ERROR, "Invalid %s field", key); LOG(ERROR) << "Invalid " << key << " field";
return result; return result;
} }
result.tv_sec = strtol(json.string().c_str(), nullptr, 10); result.tv_sec = strtol(json.string().c_str(), nullptr, 10);
@ -335,9 +333,9 @@ grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims,
// issued. // issued.
if (grpc_jwt_issuer_email_domain(claims->iss) != nullptr && if (grpc_jwt_issuer_email_domain(claims->iss) != nullptr &&
claims->sub != nullptr && strcmp(claims->iss, claims->sub) != 0) { claims->sub != nullptr && strcmp(claims->iss, claims->sub) != 0) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Email issuer (" << claims->iss
"Email issuer (%s) cannot assert another subject (%s) than itself.", << ") cannot assert another subject (" << claims->sub
claims->iss, claims->sub); << ") than itself.";
return GRPC_JWT_VERIFIER_BAD_SUBJECT; return GRPC_JWT_VERIFIER_BAD_SUBJECT;
} }
@ -347,9 +345,9 @@ grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims,
audience_ok = claims->aud != nullptr && strcmp(audience, claims->aud) == 0; audience_ok = claims->aud != nullptr && strcmp(audience, claims->aud) == 0;
} }
if (!audience_ok) { if (!audience_ok) {
gpr_log(GPR_ERROR, "Audience mismatch: expected %s and found %s.", LOG(ERROR) << "Audience mismatch: expected "
audience == nullptr ? "NULL" : audience, << (audience == nullptr ? "NULL" : audience) << " and found "
claims->aud == nullptr ? "NULL" : claims->aud); << (claims->aud == nullptr ? "NULL" : claims->aud);
return GRPC_JWT_VERIFIER_BAD_AUDIENCE; return GRPC_JWT_VERIFIER_BAD_AUDIENCE;
} }
return GRPC_JWT_VERIFIER_OK; return GRPC_JWT_VERIFIER_OK;
@ -435,8 +433,7 @@ static Json json_from_http(const grpc_http_response* response) {
return Json(); // JSON null return Json(); // JSON null
} }
if (response->status != 200) { if (response->status != 200) {
gpr_log(GPR_ERROR, "Call to http server failed with error %d.", LOG(ERROR) << "Call to http server failed with error " << response->status;
response->status);
return Json(); // JSON null return Json(); // JSON null
} }
auto json = grpc_core::JsonParse( auto json = grpc_core::JsonParse(
@ -535,7 +532,7 @@ static EVP_PKEY* pkey_from_jwk(const Json& json, const char* kty) {
CHECK(json.type() == Json::Type::kObject); CHECK(json.type() == Json::Type::kObject);
CHECK_NE(kty, nullptr); CHECK_NE(kty, nullptr);
if (strcmp(kty, "RSA") != 0) { if (strcmp(kty, "RSA") != 0) {
gpr_log(GPR_ERROR, "Unsupported key type %s.", kty); LOG(ERROR) << "Unsupported key type " << kty;
goto end; goto end;
} }
#if OPENSSL_VERSION_NUMBER < 0x30000000L #if OPENSSL_VERSION_NUMBER < 0x30000000L
@ -646,9 +643,8 @@ static EVP_PKEY* find_verification_key(const Json& json, const char* header_alg,
return pkey_from_jwk(jkey, kty); return pkey_from_jwk(jkey, kty);
} }
} }
gpr_log(GPR_ERROR, LOG(ERROR) << "Could not find matching key in key set for kid=" << header_kid
"Could not find matching key in key set for kid=%s and alg=%s", << " and alg=" << header_alg;
header_kid, header_alg);
return nullptr; return nullptr;
} }
@ -700,8 +696,8 @@ static void on_keys_retrieved(void* user_data, grpc_error_handle /*error*/) {
verification_key = verification_key =
find_verification_key(json, ctx->header->alg, ctx->header->kid); find_verification_key(json, ctx->header->alg, ctx->header->kid);
if (verification_key == nullptr) { if (verification_key == nullptr) {
gpr_log(GPR_ERROR, "Could not find verification key with kid %s.", LOG(ERROR) << "Could not find verification key with kid "
ctx->header->kid); << ctx->header->kid;
status = GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR; status = GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR;
goto end; goto end;
} }
@ -748,7 +744,7 @@ static void on_openid_config_retrieved(void* user_data,
jwks_uri = validate_string_field(*cur, "jwks_uri"); jwks_uri = validate_string_field(*cur, "jwks_uri");
if (jwks_uri == nullptr) goto error; if (jwks_uri == nullptr) goto error;
if (strstr(jwks_uri, "https://") != jwks_uri) { if (strstr(jwks_uri, "https://") != jwks_uri) {
gpr_log(GPR_ERROR, "Invalid non https jwks_uri: %s.", jwks_uri); LOG(ERROR) << "Invalid non https jwks_uri: " << jwks_uri;
goto error; goto error;
} }
jwks_uri += 8; jwks_uri += 8;

@ -29,7 +29,6 @@
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -86,9 +85,8 @@ grpc_ssl_credentials::create_security_connector(
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds, grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
const char* target, grpc_core::ChannelArgs* args) { const char* target, grpc_core::ChannelArgs* args) {
if (config_.pem_root_certs == nullptr) { if (config_.pem_root_certs == nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR) << "No root certs in config. Client-side security connector "
"No root certs in config. Client-side security connector must have " "must have root certs.";
"root certs.");
return nullptr; return nullptr;
} }
absl::optional<std::string> overridden_target_name = absl::optional<std::string> overridden_target_name =
@ -112,9 +110,7 @@ grpc_ssl_credentials::create_security_connector(
&config_, config_.pem_root_certs, root_store_, session_cache, &config_, config_.pem_root_certs, root_store_, session_cache,
&factory_with_cache); &factory_with_cache);
if (status != GRPC_SECURITY_OK) { if (status != GRPC_SECURITY_OK) {
gpr_log(GPR_ERROR, LOG(ERROR) << "InitializeClientHandshakerFactory returned bad status.";
"InitializeClientHandshakerFactory returned bad "
"status.");
return nullptr; return nullptr;
} }
security_connector = grpc_ssl_channel_security_connector_create( security_connector = grpc_ssl_channel_security_connector_create(
@ -197,9 +193,8 @@ grpc_security_status grpc_ssl_credentials::InitializeClientHandshakerFactory(
config->pem_key_cert_pair->cert_chain != nullptr; config->pem_key_cert_pair->cert_chain != nullptr;
tsi_ssl_client_handshaker_options options; tsi_ssl_client_handshaker_options options;
if (pem_root_certs == nullptr) { if (pem_root_certs == nullptr) {
gpr_log( LOG(ERROR) << "Handshaker factory creation failed. pem_root_certs cannot "
GPR_ERROR, "be nullptr";
"Handshaker factory creation failed. pem_root_certs cannot be nullptr");
return GRPC_SECURITY_ERROR; return GRPC_SECURITY_ERROR;
} }
options.pem_root_certs = pem_root_certs; options.pem_root_certs = pem_root_certs;
@ -218,8 +213,8 @@ grpc_security_status grpc_ssl_credentials::InitializeClientHandshakerFactory(
handshaker_factory); handshaker_factory);
gpr_free(options.alpn_protocols); gpr_free(options.alpn_protocols);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", LOG(ERROR) << "Handshaker factory creation failed with "
tsi_result_to_string(result)); << tsi_result_to_string(result);
return GRPC_SECURITY_ERROR; return GRPC_SECURITY_ERROR;
} }
return GRPC_SECURITY_OK; return GRPC_SECURITY_OK;
@ -454,16 +449,14 @@ grpc_server_credentials* grpc_ssl_server_credentials_create_with_options(
grpc_server_credentials* retval = nullptr; grpc_server_credentials* retval = nullptr;
if (options == nullptr) { if (options == nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Invalid options trying to create SSL server credentials.";
"Invalid options trying to create SSL server credentials.");
goto done; goto done;
} }
if (options->certificate_config == nullptr && if (options->certificate_config == nullptr &&
options->certificate_config_fetcher == nullptr) { options->certificate_config_fetcher == nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR) << "SSL server credentials options must specify either "
"SSL server credentials options must specify either " "certificate config or fetcher.";
"certificate config or fetcher.");
goto done; goto done;
} else if (options->certificate_config_fetcher != nullptr && } else if (options->certificate_config_fetcher != nullptr &&
options->certificate_config_fetcher->cb == nullptr) { options->certificate_config_fetcher->cb == nullptr) {

@ -24,11 +24,11 @@
#include <vector> #include <vector>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include <grpc/credentials.h> #include <grpc/credentials.h>
#include <grpc/slice.h> #include <grpc/slice.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
@ -123,9 +123,9 @@ FileWatcherCertificateProvider::FileWatcherCertificateProvider(
refresh_interval_sec_(refresh_interval_sec), refresh_interval_sec_(refresh_interval_sec),
distributor_(MakeRefCounted<grpc_tls_certificate_distributor>()) { distributor_(MakeRefCounted<grpc_tls_certificate_distributor>()) {
if (refresh_interval_sec_ < kMinimumFileWatcherRefreshIntervalSeconds) { if (refresh_interval_sec_ < kMinimumFileWatcherRefreshIntervalSeconds) {
gpr_log(GPR_INFO, LOG(INFO) << "FileWatcherCertificateProvider refresh_interval_sec_ set to "
"FileWatcherCertificateProvider refresh_interval_sec_ set to value " "value less than minimum. Overriding configured value to "
"less than minimum. Overriding configured value to minimum."); "minimum.";
refresh_interval_sec_ = kMinimumFileWatcherRefreshIntervalSeconds; refresh_interval_sec_ = kMinimumFileWatcherRefreshIntervalSeconds;
} }
// Private key and identity cert files must be both set or both unset. // Private key and identity cert files must be both set or both unset.
@ -284,9 +284,8 @@ FileWatcherCertificateProvider::ReadRootCertificatesFromFile(
auto root_slice = auto root_slice =
LoadFile(root_cert_full_path, /*add_null_terminator=*/false); LoadFile(root_cert_full_path, /*add_null_terminator=*/false);
if (!root_slice.ok()) { if (!root_slice.ok()) {
gpr_log(GPR_ERROR, "Reading file %s failed: %s", LOG(ERROR) << "Reading file " << root_cert_full_path
root_cert_full_path.c_str(), << " failed: " << root_slice.status();
root_slice.status().ToString().c_str());
return absl::nullopt; return absl::nullopt;
} }
return std::string(root_slice->as_string_view()); return std::string(root_slice->as_string_view());
@ -316,34 +315,29 @@ FileWatcherCertificateProvider::ReadIdentityKeyCertPairFromFiles(
time_t identity_key_ts_before = time_t identity_key_ts_before =
GetModificationTime(private_key_path.c_str()); GetModificationTime(private_key_path.c_str());
if (identity_key_ts_before == 0) { if (identity_key_ts_before == 0) {
gpr_log( LOG(ERROR) << "Failed to get the file's modification time of "
GPR_ERROR, << private_key_path << ". Start retrying...";
"Failed to get the file's modification time of %s. Start retrying...",
private_key_path.c_str());
continue; continue;
} }
time_t identity_cert_ts_before = time_t identity_cert_ts_before =
GetModificationTime(identity_certificate_path.c_str()); GetModificationTime(identity_certificate_path.c_str());
if (identity_cert_ts_before == 0) { if (identity_cert_ts_before == 0) {
gpr_log( LOG(ERROR) << "Failed to get the file's modification time of "
GPR_ERROR, << identity_certificate_path << ". Start retrying...";
"Failed to get the file's modification time of %s. Start retrying...",
identity_certificate_path.c_str());
continue; continue;
} }
// Read the identity files. // Read the identity files.
auto key_slice = LoadFile(private_key_path, /*add_null_terminator=*/false); auto key_slice = LoadFile(private_key_path, /*add_null_terminator=*/false);
if (!key_slice.ok()) { if (!key_slice.ok()) {
gpr_log(GPR_ERROR, "Reading file %s failed: %s. Start retrying...", LOG(ERROR) << "Reading file " << private_key_path
private_key_path.c_str(), key_slice.status().ToString().c_str()); << " failed: " << key_slice.status() << ". Start retrying...";
continue; continue;
} }
auto cert_slice = auto cert_slice =
LoadFile(identity_certificate_path, /*add_null_terminator=*/false); LoadFile(identity_certificate_path, /*add_null_terminator=*/false);
if (!cert_slice.ok()) { if (!cert_slice.ok()) {
gpr_log(GPR_ERROR, "Reading file %s failed: %s. Start retrying...", LOG(ERROR) << "Reading file " << identity_certificate_path
identity_certificate_path.c_str(), << " failed: " << cert_slice.status() << ". Start retrying...";
cert_slice.status().ToString().c_str());
continue; continue;
} }
std::string private_key(key_slice->as_string_view()); std::string private_key(key_slice->as_string_view());
@ -354,25 +348,22 @@ FileWatcherCertificateProvider::ReadIdentityKeyCertPairFromFiles(
time_t identity_key_ts_after = time_t identity_key_ts_after =
GetModificationTime(private_key_path.c_str()); GetModificationTime(private_key_path.c_str());
if (identity_key_ts_before != identity_key_ts_after) { if (identity_key_ts_before != identity_key_ts_after) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Last modified time before and after reading "
"Last modified time before and after reading %s is not the same. " << private_key_path << " is not the same. Start retrying...";
"Start retrying...",
private_key_path.c_str());
continue; continue;
} }
time_t identity_cert_ts_after = time_t identity_cert_ts_after =
GetModificationTime(identity_certificate_path.c_str()); GetModificationTime(identity_certificate_path.c_str());
if (identity_cert_ts_before != identity_cert_ts_after) { if (identity_cert_ts_before != identity_cert_ts_after) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Last modified time before and after reading "
"Last modified time before and after reading %s is not the same. " << identity_certificate_path
"Start retrying...", << " is not the same. Start retrying...";
identity_certificate_path.c_str());
continue; continue;
} }
return identity_pairs; return identity_pairs;
} }
gpr_log(GPR_ERROR, LOG(ERROR) << "All retry attempts failed. Will try again after the next "
"All retry attempts failed. Will try again after the next interval."); "interval.";
return absl::nullopt; return absl::nullopt;
} }

@ -24,7 +24,6 @@
#include "absl/log/log.h" #include "absl/log/log.h"
#include <grpc/grpc_crl_provider.h> #include <grpc/grpc_crl_provider.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/debug/trace.h" #include "src/core/lib/debug/trace.h"
@ -129,8 +128,8 @@ void grpc_tls_credentials_options_set_tls_session_key_log_file_path(
// Tls session key logging is assumed to be enabled if the specified log // Tls session key logging is assumed to be enabled if the specified log
// file is non-empty. // file is non-empty.
if (path != nullptr) { if (path != nullptr) {
gpr_log(GPR_INFO, LOG(INFO) << "Enabling TLS session key logging with keys stored at: "
"Enabling TLS session key logging with keys stored at: %s", path); << path;
} else { } else {
LOG(INFO) << "Disabling TLS session key logging"; LOG(INFO) << "Disabling TLS session key logging";
} }

@ -35,14 +35,13 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_map.h"
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h" #include "absl/strings/str_join.h"
#include "absl/types/span.h" #include "absl/types/span.h"
#include <grpc/support/log.h>
#include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/gprpp/directory_reader.h" #include "src/core/lib/gprpp/directory_reader.h"
#include "src/core/lib/gprpp/load_file.h" #include "src/core/lib/gprpp/load_file.h"
@ -130,9 +129,8 @@ absl::StatusOr<std::shared_ptr<CrlProvider>> CreateStaticCrlProvider(
} }
bool inserted = crl_map.emplace((*crl)->Issuer(), std::move(*crl)).second; bool inserted = crl_map.emplace((*crl)->Issuer(), std::move(*crl)).second;
if (!inserted) { if (!inserted) {
gpr_log(GPR_ERROR, LOG(ERROR) << "StaticCrlProvider received multiple CRLs with the same "
"StaticCrlProvider received multiple CRLs with the same issuer. " "issuer. The first one in the span will be used.";
"The first one in the span will be used.");
} }
} }
StaticCrlProvider provider = StaticCrlProvider(std::move(crl_map)); StaticCrlProvider provider = StaticCrlProvider(std::move(crl_map));

@ -28,7 +28,6 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security_constants.h> #include <grpc/grpc_security_constants.h>
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
@ -63,9 +62,8 @@ bool CredentialOptionSanityCheck(grpc_tls_credentials_options* options,
return false; return false;
} }
if (!options->crl_directory().empty() && options->crl_provider() != nullptr) { if (!options->crl_directory().empty() && options->crl_provider() != nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Setting crl_directory and crl_provider not supported. Using "
"Setting crl_directory and crl_provider not supported. Using the " "the crl_provider.";
"crl_provider.");
// TODO(gtcooke94) - Maybe return false here. Right now object lifetime of // TODO(gtcooke94) - Maybe return false here. Right now object lifetime of
// this options struct is leaky if false is returned and represents a more // this options struct is leaky if false is returned and represents a more
// complex fix to handle in another PR. // complex fix to handle in another PR.
@ -74,21 +72,20 @@ bool CredentialOptionSanityCheck(grpc_tls_credentials_options* options,
// indicate callers are doing something wrong with the API. // indicate callers are doing something wrong with the API.
if (is_client && options->cert_request_type() != if (is_client && options->cert_request_type() !=
GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE) { GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE) {
gpr_log(GPR_ERROR, LOG(ERROR)
"Client's credentials options should not set cert_request_type."); << "Client's credentials options should not set cert_request_type.";
} }
if (!is_client && !options->verify_server_cert()) { if (!is_client && !options->verify_server_cert()) {
gpr_log(GPR_ERROR, LOG(ERROR)
"Server's credentials options should not set verify_server_cert."); << "Server's credentials options should not set verify_server_cert.";
} }
// In the following conditions, there could be severe security issues. // In the following conditions, there could be severe security issues.
if (is_client && options->certificate_verifier() == nullptr) { if (is_client && options->certificate_verifier() == nullptr) {
// If no verifier is specified on the client side, use the hostname verifier // If no verifier is specified on the client side, use the hostname verifier
// as default. Users who want to bypass all the verifier check should // as default. Users who want to bypass all the verifier check should
// implement an external verifier instead. // implement an external verifier instead.
gpr_log(GPR_INFO, LOG(INFO) << "No verifier specified on the client side. Using default "
"No verifier specified on the client side. Using default hostname " "hostname verifier";
"verifier");
options->set_certificate_verifier( options->set_certificate_verifier(
grpc_core::MakeRefCounted<grpc_core::HostNameCertificateVerifier>()); grpc_core::MakeRefCounted<grpc_core::HostNameCertificateVerifier>());
} }

@ -22,11 +22,11 @@
#include <algorithm> #include <algorithm>
#include "absl/log/log.h"
#include "absl/strings/ascii.h" #include "absl/strings/ascii.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
namespace grpc_core { namespace grpc_core {
@ -99,11 +99,11 @@ absl::string_view GetAuthPropertyValue(grpc_auth_context* context,
grpc_auth_context_find_properties_by_name(context, property_name); grpc_auth_context_find_properties_by_name(context, property_name);
const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it); const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
if (prop == nullptr) { if (prop == nullptr) {
gpr_log(GPR_DEBUG, "No value found for %s property.", property_name); VLOG(2) << "No value found for " << property_name << " property.";
return ""; return "";
} }
if (grpc_auth_property_iterator_next(&it) != nullptr) { if (grpc_auth_property_iterator_next(&it) != nullptr) {
gpr_log(GPR_DEBUG, "Multiple values found for %s property.", property_name); VLOG(2) << "Multiple values found for " << property_name << " property.";
return ""; return "";
} }
return absl::string_view(prop->value, prop->value_length); return absl::string_view(prop->value, prop->value_length);
@ -120,7 +120,7 @@ std::vector<absl::string_view> GetAuthPropertyArray(grpc_auth_context* context,
prop = grpc_auth_property_iterator_next(&it); prop = grpc_auth_property_iterator_next(&it);
} }
if (values.empty()) { if (values.empty()) {
gpr_log(GPR_DEBUG, "No value found for %s property.", property_name); VLOG(2) << "No value found for " << property_name << " property.";
} }
return values; return values;
} }

@ -24,6 +24,7 @@
#include <utility> #include <utility>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
@ -33,7 +34,6 @@
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/slice.h> #include <grpc/slice.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -187,8 +187,7 @@ namespace internal {
RefCountedPtr<grpc_auth_context> grpc_alts_auth_context_from_tsi_peer( RefCountedPtr<grpc_auth_context> grpc_alts_auth_context_from_tsi_peer(
const tsi_peer* peer) { const tsi_peer* peer) {
if (peer == nullptr) { if (peer == nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Invalid arguments to grpc_alts_auth_context_from_tsi_peer()";
"Invalid arguments to grpc_alts_auth_context_from_tsi_peer()");
return nullptr; return nullptr;
} }
// Validate certificate type. // Validate certificate type.
@ -197,21 +196,21 @@ RefCountedPtr<grpc_auth_context> grpc_alts_auth_context_from_tsi_peer(
if (cert_type_prop == nullptr || if (cert_type_prop == nullptr ||
strncmp(cert_type_prop->value.data, TSI_ALTS_CERTIFICATE_TYPE, strncmp(cert_type_prop->value.data, TSI_ALTS_CERTIFICATE_TYPE,
cert_type_prop->value.length) != 0) { cert_type_prop->value.length) != 0) {
gpr_log(GPR_ERROR, "Invalid or missing certificate type property."); LOG(ERROR) << "Invalid or missing certificate type property.";
return nullptr; return nullptr;
} }
// Check if security level exists. // Check if security level exists.
const tsi_peer_property* security_level_prop = const tsi_peer_property* security_level_prop =
tsi_peer_get_property_by_name(peer, TSI_SECURITY_LEVEL_PEER_PROPERTY); tsi_peer_get_property_by_name(peer, TSI_SECURITY_LEVEL_PEER_PROPERTY);
if (security_level_prop == nullptr) { if (security_level_prop == nullptr) {
gpr_log(GPR_ERROR, "Missing security level property."); LOG(ERROR) << "Missing security level property.";
return nullptr; return nullptr;
} }
// Validate RPC protocol versions. // Validate RPC protocol versions.
const tsi_peer_property* rpc_versions_prop = const tsi_peer_property* rpc_versions_prop =
tsi_peer_get_property_by_name(peer, TSI_ALTS_RPC_VERSIONS); tsi_peer_get_property_by_name(peer, TSI_ALTS_RPC_VERSIONS);
if (rpc_versions_prop == nullptr) { if (rpc_versions_prop == nullptr) {
gpr_log(GPR_ERROR, "Missing rpc protocol versions property."); LOG(ERROR) << "Missing rpc protocol versions property.";
return nullptr; return nullptr;
} }
grpc_gcp_rpc_protocol_versions local_versions, peer_versions; grpc_gcp_rpc_protocol_versions local_versions, peer_versions;
@ -222,21 +221,21 @@ RefCountedPtr<grpc_auth_context> grpc_alts_auth_context_from_tsi_peer(
grpc_gcp_rpc_protocol_versions_decode(slice, &peer_versions); grpc_gcp_rpc_protocol_versions_decode(slice, &peer_versions);
CSliceUnref(slice); CSliceUnref(slice);
if (!decode_result) { if (!decode_result) {
gpr_log(GPR_ERROR, "Invalid peer rpc protocol versions."); LOG(ERROR) << "Invalid peer rpc protocol versions.";
return nullptr; return nullptr;
} }
// TODO(unknown): Pass highest common rpc protocol version to grpc caller. // TODO(unknown): Pass highest common rpc protocol version to grpc caller.
bool check_result = grpc_gcp_rpc_protocol_versions_check( bool check_result = grpc_gcp_rpc_protocol_versions_check(
&local_versions, &peer_versions, nullptr); &local_versions, &peer_versions, nullptr);
if (!check_result) { if (!check_result) {
gpr_log(GPR_ERROR, "Mismatch of local and peer rpc protocol versions."); LOG(ERROR) << "Mismatch of local and peer rpc protocol versions.";
return nullptr; return nullptr;
} }
// Validate ALTS Context. // Validate ALTS Context.
const tsi_peer_property* alts_context_prop = const tsi_peer_property* alts_context_prop =
tsi_peer_get_property_by_name(peer, TSI_ALTS_CONTEXT); tsi_peer_get_property_by_name(peer, TSI_ALTS_CONTEXT);
if (alts_context_prop == nullptr) { if (alts_context_prop == nullptr) {
gpr_log(GPR_ERROR, "Missing alts context property."); LOG(ERROR) << "Missing alts context property.";
return nullptr; return nullptr;
} }
// Create auth context. // Create auth context.
@ -269,7 +268,7 @@ RefCountedPtr<grpc_auth_context> grpc_alts_auth_context_from_tsi_peer(
} }
} }
if (!grpc_auth_context_peer_is_authenticated(ctx.get())) { if (!grpc_auth_context_peer_is_authenticated(ctx.get())) {
gpr_log(GPR_ERROR, "Invalid unauthenticated peer."); LOG(ERROR) << "Invalid unauthenticated peer.";
ctx.reset(DEBUG_LOCATION, "test"); ctx.reset(DEBUG_LOCATION, "test");
return nullptr; return nullptr;
} }
@ -285,9 +284,8 @@ grpc_alts_channel_security_connector_create(
grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds, grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
const char* target_name) { const char* target_name) {
if (channel_creds == nullptr || target_name == nullptr) { if (channel_creds == nullptr || target_name == nullptr) {
gpr_log( LOG(ERROR)
GPR_ERROR, << "Invalid arguments to grpc_alts_channel_security_connector_create()";
"Invalid arguments to grpc_alts_channel_security_connector_create()");
return nullptr; return nullptr;
} }
return grpc_core::MakeRefCounted<grpc_alts_channel_security_connector>( return grpc_core::MakeRefCounted<grpc_alts_channel_security_connector>(
@ -298,9 +296,8 @@ grpc_core::RefCountedPtr<grpc_server_security_connector>
grpc_alts_server_security_connector_create( grpc_alts_server_security_connector_create(
grpc_core::RefCountedPtr<grpc_server_credentials> server_creds) { grpc_core::RefCountedPtr<grpc_server_credentials> server_creds) {
if (server_creds == nullptr) { if (server_creds == nullptr) {
gpr_log( LOG(ERROR)
GPR_ERROR, << "Invalid arguments to grpc_alts_server_security_connector_create()";
"Invalid arguments to grpc_alts_server_security_connector_create()");
return nullptr; return nullptr;
} }
return grpc_core::MakeRefCounted<grpc_alts_server_security_connector>( return grpc_core::MakeRefCounted<grpc_alts_server_security_connector>(

@ -25,6 +25,7 @@
#include <utility> #include <utility>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
@ -165,28 +166,30 @@ class grpc_fake_channel_security_connector final
gpr_string_split(expected_targets_->c_str(), ";", &lbs_and_backends, gpr_string_split(expected_targets_->c_str(), ";", &lbs_and_backends,
&lbs_and_backends_size); &lbs_and_backends_size);
if (lbs_and_backends_size > 2 || lbs_and_backends_size == 0) { if (lbs_and_backends_size > 2 || lbs_and_backends_size == 0) {
gpr_log(GPR_ERROR, "Invalid expected targets arg value: '%s'", LOG(ERROR) << "Invalid expected targets arg value: '"
expected_targets_->c_str()); << expected_targets_->c_str() << "'";
goto done; goto done;
} }
if (is_lb_channel_) { if (is_lb_channel_) {
if (lbs_and_backends_size != 2) { if (lbs_and_backends_size != 2) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Invalid expected targets arg value: '"
"Invalid expected targets arg value: '%s'. Expectations for LB " << expected_targets_->c_str()
"channels must be of the form 'be1,be2,be3,...;lb1,lb2,...", << "'. Expectations for LB channels must be of the form "
expected_targets_->c_str()); "'be1,be2,be3,...;lb1,lb2,...";
goto done; goto done;
} }
if (!fake_check_target(target_, lbs_and_backends[1])) { if (!fake_check_target(target_, lbs_and_backends[1])) {
gpr_log(GPR_ERROR, "LB target '%s' not found in expected set '%s'", LOG(ERROR) << "LB target '" << target_
target_, lbs_and_backends[1]); << "' not found in expected set '" << lbs_and_backends[1]
<< "'";
goto done; goto done;
} }
success = true; success = true;
} else { } else {
if (!fake_check_target(target_, lbs_and_backends[0])) { if (!fake_check_target(target_, lbs_and_backends[0])) {
gpr_log(GPR_ERROR, "Backend target '%s' not found in expected set '%s'", LOG(ERROR) << "Backend target '" << target_
target_, lbs_and_backends[0]); << "' not found in expected set '" << lbs_and_backends[0]
<< "'";
goto done; goto done;
} }
success = true; success = true;

@ -35,7 +35,6 @@
#include "absl/log/log.h" #include "absl/log/log.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/config/config_vars.h" #include "src/core/lib/config/config_vars.h"
#include "src/core/lib/gprpp/load_file.h" #include "src/core/lib/gprpp/load_file.h"
@ -81,8 +80,7 @@ void GetAbsoluteFilePath(const char* valid_file_dir,
int path_len = snprintf(path_buffer, MAXPATHLEN, "%s/%s", valid_file_dir, int path_len = snprintf(path_buffer, MAXPATHLEN, "%s/%s", valid_file_dir,
file_entry_name); file_entry_name);
if (path_len == 0) { if (path_len == 0) {
gpr_log(GPR_ERROR, "failed to get absolute path for file: %s", LOG(ERROR) << "failed to get absolute path for file: " << file_entry_name;
file_entry_name);
} }
} }
} }

@ -24,6 +24,7 @@
#include <utility> #include <utility>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
@ -33,7 +34,6 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security_constants.h> #include <grpc/grpc_security_constants.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -99,8 +99,7 @@ void local_check_peer(tsi_peer peer, grpc_endpoint* ep,
absl::string_view local_addr = grpc_endpoint_get_local_address(ep); absl::string_view local_addr = grpc_endpoint_get_local_address(ep);
absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(local_addr); absl::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(local_addr);
if (!uri.ok() || !grpc_parse_uri(*uri, &resolved_addr)) { if (!uri.ok() || !grpc_parse_uri(*uri, &resolved_addr)) {
gpr_log(GPR_ERROR, "Could not parse endpoint address: %s", LOG(ERROR) << "Could not parse endpoint address: " << local_addr;
std::string(local_addr.data(), local_addr.size()).c_str());
} else { } else {
grpc_resolved_address addr_normalized; grpc_resolved_address addr_normalized;
grpc_resolved_address* addr = grpc_resolved_address* addr =
@ -269,9 +268,8 @@ grpc_local_channel_security_connector_create(
grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds, grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
const grpc_core::ChannelArgs& args, const char* target_name) { const grpc_core::ChannelArgs& args, const char* target_name) {
if (channel_creds == nullptr || target_name == nullptr) { if (channel_creds == nullptr || target_name == nullptr) {
gpr_log( LOG(ERROR) << "Invalid arguments to "
GPR_ERROR, "grpc_local_channel_security_connector_create()";
"Invalid arguments to grpc_local_channel_security_connector_create()");
return nullptr; return nullptr;
} }
// Perform sanity check on UDS address. For TCP local connection, the check // Perform sanity check on UDS address. For TCP local connection, the check
@ -283,9 +281,8 @@ grpc_local_channel_security_connector_create(
if (creds->connect_type() == UDS && if (creds->connect_type() == UDS &&
!absl::StartsWith(server_uri_str, GRPC_UDS_URI_PATTERN) && !absl::StartsWith(server_uri_str, GRPC_UDS_URI_PATTERN) &&
!absl::StartsWith(server_uri_str, GRPC_ABSTRACT_UDS_URI_PATTERN)) { !absl::StartsWith(server_uri_str, GRPC_ABSTRACT_UDS_URI_PATTERN)) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Invalid UDS target name to "
"Invalid UDS target name to " "grpc_local_channel_security_connector_create()";
"grpc_local_channel_security_connector_create()");
return nullptr; return nullptr;
} }
return grpc_core::MakeRefCounted<grpc_local_channel_security_connector>( return grpc_core::MakeRefCounted<grpc_local_channel_security_connector>(
@ -296,9 +293,8 @@ grpc_core::RefCountedPtr<grpc_server_security_connector>
grpc_local_server_security_connector_create( grpc_local_server_security_connector_create(
grpc_core::RefCountedPtr<grpc_server_credentials> server_creds) { grpc_core::RefCountedPtr<grpc_server_credentials> server_creds) {
if (server_creds == nullptr) { if (server_creds == nullptr) {
gpr_log( LOG(ERROR)
GPR_ERROR, << "Invalid arguments to grpc_local_server_security_connector_create()";
"Invalid arguments to grpc_local_server_security_connector_create()");
return nullptr; return nullptr;
} }
return grpc_core::MakeRefCounted<grpc_local_server_security_connector>( return grpc_core::MakeRefCounted<grpc_local_server_security_connector>(

@ -32,7 +32,6 @@
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/handshaker/handshaker.h" #include "src/core/handshaker/handshaker.h"
@ -113,8 +112,8 @@ class grpc_ssl_channel_security_connector final
/*network_bio_buf_size=*/0, /*network_bio_buf_size=*/0,
/*ssl_bio_buf_size=*/0, &tsi_hs); /*ssl_bio_buf_size=*/0, &tsi_hs);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.", LOG(ERROR) << "Handshaker creation failed with error "
tsi_result_to_string(result)); << tsi_result_to_string(result);
return; return;
} }
// Create handshakers. // Create handshakers.
@ -205,8 +204,7 @@ class grpc_ssl_server_security_connector
if (has_cert_config_fetcher()) { if (has_cert_config_fetcher()) {
// Load initial credentials from certificate_config_fetcher: // Load initial credentials from certificate_config_fetcher:
if (!try_fetch_ssl_server_credentials()) { if (!try_fetch_ssl_server_credentials()) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Failed loading SSL server credentials from fetcher.";
"Failed loading SSL server credentials from fetcher.");
return GRPC_SECURITY_ERROR; return GRPC_SECURITY_ERROR;
} }
} else { } else {
@ -237,8 +235,8 @@ class grpc_ssl_server_security_connector
&options, &server_handshaker_factory_); &options, &server_handshaker_factory_);
gpr_free(alpn_protocol_strings); gpr_free(alpn_protocol_strings);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", LOG(ERROR) << "Handshaker factory creation failed with "
tsi_result_to_string(result)); << tsi_result_to_string(result);
return GRPC_SECURITY_ERROR; return GRPC_SECURITY_ERROR;
} }
} }
@ -255,8 +253,8 @@ class grpc_ssl_server_security_connector
server_handshaker_factory_, /*network_bio_buf_size=*/0, server_handshaker_factory_, /*network_bio_buf_size=*/0,
/*ssl_bio_buf_size=*/0, &tsi_hs); /*ssl_bio_buf_size=*/0, &tsi_hs);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.", LOG(ERROR) << "Handshaker creation failed with error "
tsi_result_to_string(result)); << tsi_result_to_string(result);
return; return;
} }
// Create handshakers. // Create handshakers.
@ -300,9 +298,8 @@ class grpc_ssl_server_security_connector
status = try_replace_server_handshaker_factory(certificate_config); status = try_replace_server_handshaker_factory(certificate_config);
} else { } else {
// Log error, continue using previously-loaded credentials. // Log error, continue using previously-loaded credentials.
gpr_log(GPR_ERROR, LOG(ERROR) << "Failed fetching new server credentials, continuing to "
"Failed fetching new server credentials, continuing to " "use previously-loaded credentials.";
"use previously-loaded credentials.");
status = false; status = false;
} }
@ -319,12 +316,12 @@ class grpc_ssl_server_security_connector
bool try_replace_server_handshaker_factory( bool try_replace_server_handshaker_factory(
const grpc_ssl_server_certificate_config* config) { const grpc_ssl_server_certificate_config* config) {
if (config == nullptr) { if (config == nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR)
"Server certificate config callback returned invalid (NULL) " << "Server certificate config callback returned invalid (NULL) "
"config."); "config.";
return false; return false;
} }
gpr_log(GPR_DEBUG, "Using new server certificate config (%p).", config); VLOG(2) << "Using new server certificate config (" << config << ").";
size_t num_alpn_protocols = 0; size_t num_alpn_protocols = 0;
const char** alpn_protocol_strings = const char** alpn_protocol_strings =
@ -352,8 +349,8 @@ class grpc_ssl_server_security_connector
gpr_free(alpn_protocol_strings); gpr_free(alpn_protocol_strings);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", LOG(ERROR) << "Handshaker factory creation failed with "
tsi_result_to_string(result)); << tsi_result_to_string(result);
return false; return false;
} }
set_server_handshaker_factory(new_handshaker_factory); set_server_handshaker_factory(new_handshaker_factory);

@ -36,7 +36,6 @@
#include <grpc/grpc_crl_provider.h> #include <grpc/grpc_crl_provider.h>
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
@ -420,9 +419,8 @@ grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
const char* root_certs; const char* root_certs;
const tsi_ssl_root_certs_store* root_store; const tsi_ssl_root_certs_store* root_store;
if (pem_root_certs == nullptr && !skip_server_certificate_verification) { if (pem_root_certs == nullptr && !skip_server_certificate_verification) {
gpr_log(GPR_INFO, LOG(INFO) << "No root certificates specified; use ones stored in system "
"No root certificates specified; use ones stored in system default " "default locations instead";
"locations instead");
// Use default root certificates. // Use default root certificates.
root_certs = grpc_core::DefaultSslRootStore::GetPemRootCerts(); root_certs = grpc_core::DefaultSslRootStore::GetPemRootCerts();
if (root_certs == nullptr) { if (root_certs == nullptr) {
@ -459,8 +457,8 @@ grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
handshaker_factory); handshaker_factory);
gpr_free(options.alpn_protocols); gpr_free(options.alpn_protocols);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", LOG(ERROR) << "Handshaker factory creation failed with "
tsi_result_to_string(result)); << tsi_result_to_string(result);
return GRPC_SECURITY_ERROR; return GRPC_SECURITY_ERROR;
} }
return GRPC_SECURITY_OK; return GRPC_SECURITY_OK;
@ -498,8 +496,8 @@ grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init(
handshaker_factory); handshaker_factory);
gpr_free(alpn_protocol_strings); gpr_free(alpn_protocol_strings);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", LOG(ERROR) << "Handshaker factory creation failed with "
tsi_result_to_string(result)); << tsi_result_to_string(result);
return GRPC_SECURITY_ERROR; return GRPC_SECURITY_ERROR;
} }
return GRPC_SECURITY_OK; return GRPC_SECURITY_OK;
@ -576,9 +574,8 @@ grpc_slice DefaultSslRootStore::ComputePemRootCerts() {
auto slice = auto slice =
LoadFile(default_root_certs_path, /*add_null_terminator=*/true); LoadFile(default_root_certs_path, /*add_null_terminator=*/true);
if (!slice.ok()) { if (!slice.ok()) {
gpr_log(GPR_ERROR, "error loading file %s: %s", LOG(ERROR) << "error loading file " << default_root_certs_path << ": "
default_root_certs_path.c_str(), << slice.status();
slice.status().ToString().c_str());
} else { } else {
result = std::move(*slice); result = std::move(*slice);
} }
@ -604,8 +601,8 @@ grpc_slice DefaultSslRootStore::ComputePemRootCerts() {
if (result.empty() && ovrd_res != GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY) { if (result.empty() && ovrd_res != GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY) {
auto slice = LoadFile(installed_roots_path, /*add_null_terminator=*/true); auto slice = LoadFile(installed_roots_path, /*add_null_terminator=*/true);
if (!slice.ok()) { if (!slice.ok()) {
gpr_log(GPR_ERROR, "error loading file %s: %s", installed_roots_path, LOG(ERROR) << "error loading file " << installed_roots_path << ": "
slice.status().ToString().c_str()); << slice.status();
} else { } else {
result = std::move(*slice); result = std::move(*slice);
} }

@ -33,7 +33,6 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security_constants.h> #include <grpc/grpc_security_constants.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -247,21 +246,18 @@ TlsChannelSecurityConnector::CreateTlsChannelSecurityConnector(
const char* target_name, const char* overridden_target_name, const char* target_name, const char* overridden_target_name,
tsi_ssl_session_cache* ssl_session_cache) { tsi_ssl_session_cache* ssl_session_cache) {
if (channel_creds == nullptr) { if (channel_creds == nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR) << "channel_creds is nullptr in "
"channel_creds is nullptr in " "TlsChannelSecurityConnectorCreate()";
"TlsChannelSecurityConnectorCreate()");
return nullptr; return nullptr;
} }
if (options == nullptr) { if (options == nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR) << "options is nullptr in "
"options is nullptr in " "TlsChannelSecurityConnectorCreate()";
"TlsChannelSecurityConnectorCreate()");
return nullptr; return nullptr;
} }
if (target_name == nullptr) { if (target_name == nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR) << "target_name is nullptr in "
"target_name is nullptr in " "TlsChannelSecurityConnectorCreate()";
"TlsChannelSecurityConnectorCreate()");
return nullptr; return nullptr;
} }
return MakeRefCounted<TlsChannelSecurityConnector>( return MakeRefCounted<TlsChannelSecurityConnector>(
@ -355,8 +351,8 @@ void TlsChannelSecurityConnector::add_handshakers(
/*network_bio_buf_size=*/0, /*network_bio_buf_size=*/0,
/*ssl_bio_buf_size=*/0, &tsi_hs); /*ssl_bio_buf_size=*/0, &tsi_hs);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.", LOG(ERROR) << "Handshaker creation failed with error "
tsi_result_to_string(result)); << tsi_result_to_string(result);
} }
} }
// If tsi_hs is null, this will add a failing handshaker. // If tsi_hs is null, this will add a failing handshaker.
@ -401,9 +397,8 @@ void TlsChannelSecurityConnector::cancel_check_peer(
if (it != pending_verifier_requests_.end()) { if (it != pending_verifier_requests_.end()) {
pending_verifier_request = it->second->request(); pending_verifier_request = it->second->request();
} else { } else {
gpr_log(GPR_INFO, LOG(INFO) << "TlsChannelSecurityConnector::cancel_check_peer: no "
"TlsChannelSecurityConnector::cancel_check_peer: no " "corresponding pending request found";
"corresponding pending request found");
} }
} }
if (pending_verifier_request != nullptr) { if (pending_verifier_request != nullptr) {
@ -463,14 +458,12 @@ void TlsChannelSecurityConnector::TlsChannelCertificateWatcher::
void TlsChannelSecurityConnector::TlsChannelCertificateWatcher::OnError( void TlsChannelSecurityConnector::TlsChannelCertificateWatcher::OnError(
grpc_error_handle root_cert_error, grpc_error_handle identity_cert_error) { grpc_error_handle root_cert_error, grpc_error_handle identity_cert_error) {
if (!root_cert_error.ok()) { if (!root_cert_error.ok()) {
gpr_log(GPR_ERROR, LOG(ERROR) << "TlsChannelCertificateWatcher getting root_cert_error: "
"TlsChannelCertificateWatcher getting root_cert_error: %s", << StatusToString(root_cert_error);
StatusToString(root_cert_error).c_str());
} }
if (!identity_cert_error.ok()) { if (!identity_cert_error.ok()) {
gpr_log(GPR_ERROR, LOG(ERROR) << "TlsChannelCertificateWatcher getting identity_cert_error: "
"TlsChannelCertificateWatcher getting identity_cert_error: %s", << StatusToString(identity_cert_error);
StatusToString(identity_cert_error).c_str());
} }
} }
@ -566,15 +559,13 @@ TlsServerSecurityConnector::CreateTlsServerSecurityConnector(
RefCountedPtr<grpc_server_credentials> server_creds, RefCountedPtr<grpc_server_credentials> server_creds,
RefCountedPtr<grpc_tls_credentials_options> options) { RefCountedPtr<grpc_tls_credentials_options> options) {
if (server_creds == nullptr) { if (server_creds == nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR) << "server_creds is nullptr in "
"server_creds is nullptr in " "TlsServerSecurityConnectorCreate()";
"TlsServerSecurityConnectorCreate()");
return nullptr; return nullptr;
} }
if (options == nullptr) { if (options == nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR) << "options is nullptr in "
"options is nullptr in " "TlsServerSecurityConnectorCreate()";
"TlsServerSecurityConnectorCreate()");
return nullptr; return nullptr;
} }
return MakeRefCounted<TlsServerSecurityConnector>(std::move(server_creds), return MakeRefCounted<TlsServerSecurityConnector>(std::move(server_creds),
@ -634,8 +625,8 @@ void TlsServerSecurityConnector::add_handshakers(
server_handshaker_factory_, /*network_bio_buf_size=*/0, server_handshaker_factory_, /*network_bio_buf_size=*/0,
/*ssl_bio_buf_size=*/0, &tsi_hs); /*ssl_bio_buf_size=*/0, &tsi_hs);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.", LOG(ERROR) << "Handshaker creation failed with error "
tsi_result_to_string(result)); << tsi_result_to_string(result);
} }
} }
// If tsi_hs is null, this will add a failing handshaker. // If tsi_hs is null, this will add a failing handshaker.
@ -680,9 +671,8 @@ void TlsServerSecurityConnector::cancel_check_peer(
if (it != pending_verifier_requests_.end()) { if (it != pending_verifier_requests_.end()) {
pending_verifier_request = it->second->request(); pending_verifier_request = it->second->request();
} else { } else {
gpr_log(GPR_INFO, LOG(INFO) << "TlsServerSecurityConnector::cancel_check_peer: no "
"TlsServerSecurityConnector::cancel_check_peer: no " "corresponding pending request found";
"corresponding pending request found");
} }
} }
if (pending_verifier_request != nullptr) { if (pending_verifier_request != nullptr) {
@ -732,14 +722,12 @@ void TlsServerSecurityConnector::TlsServerCertificateWatcher::
void TlsServerSecurityConnector::TlsServerCertificateWatcher::OnError( void TlsServerSecurityConnector::TlsServerCertificateWatcher::OnError(
grpc_error_handle root_cert_error, grpc_error_handle identity_cert_error) { grpc_error_handle root_cert_error, grpc_error_handle identity_cert_error) {
if (!root_cert_error.ok()) { if (!root_cert_error.ok()) {
gpr_log(GPR_ERROR, LOG(ERROR) << "TlsServerCertificateWatcher getting root_cert_error: "
"TlsServerCertificateWatcher getting root_cert_error: %s", << StatusToString(root_cert_error);
StatusToString(root_cert_error).c_str());
} }
if (!identity_cert_error.ok()) { if (!identity_cert_error.ok()) {
gpr_log(GPR_ERROR, LOG(ERROR) << "TlsServerCertificateWatcher getting identity_cert_error: "
"TlsServerCertificateWatcher getting identity_cert_error: %s", << StatusToString(identity_cert_error);
StatusToString(identity_cert_error).c_str());
} }
} }

@ -33,7 +33,6 @@
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include "src/core/handshaker/handshaker.h" #include "src/core/handshaker/handshaker.h"
@ -96,8 +95,8 @@ class grpc_httpcli_ssl_channel_security_connector final
handshaker_factory_, secure_peer_name_, /*network_bio_buf_size=*/0, handshaker_factory_, secure_peer_name_, /*network_bio_buf_size=*/0,
/*ssl_bio_buf_size=*/0, &handshaker); /*ssl_bio_buf_size=*/0, &handshaker);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.", LOG(ERROR) << "Handshaker creation failed with error "
tsi_result_to_string(result)); << tsi_result_to_string(result);
} }
} }
handshake_mgr->Add(SecurityHandshakerCreate(handshaker, this, args)); handshake_mgr->Add(SecurityHandshakerCreate(handshaker, this, args));
@ -150,8 +149,7 @@ httpcli_ssl_channel_security_connector_create(
const char* pem_root_certs, const tsi_ssl_root_certs_store* root_store, const char* pem_root_certs, const tsi_ssl_root_certs_store* root_store,
const char* secure_peer_name) { const char* secure_peer_name) {
if (secure_peer_name != nullptr && pem_root_certs == nullptr) { if (secure_peer_name != nullptr && pem_root_certs == nullptr) {
gpr_log(GPR_ERROR, LOG(ERROR) << "Cannot assert a secure peer name without a trust root.";
"Cannot assert a secure peer name without a trust root.");
return nullptr; return nullptr;
} }
RefCountedPtr<grpc_httpcli_ssl_channel_security_connector> c = RefCountedPtr<grpc_httpcli_ssl_channel_security_connector> c =
@ -159,8 +157,8 @@ httpcli_ssl_channel_security_connector_create(
secure_peer_name == nullptr ? nullptr : gpr_strdup(secure_peer_name)); secure_peer_name == nullptr ? nullptr : gpr_strdup(secure_peer_name));
tsi_result result = c->InitHandshakerFactory(pem_root_certs, root_store); tsi_result result = c->InitHandshakerFactory(pem_root_certs, root_store);
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", LOG(ERROR) << "Handshaker factory creation failed with "
tsi_result_to_string(result)); << tsi_result_to_string(result);
return nullptr; return nullptr;
} }
return c; return c;

Loading…
Cancel
Save