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

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

@ -28,7 +28,6 @@
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.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);
if (r < 0 && r != Z_BUF_ERROR /* not fatal */) {
gpr_log(GPR_INFO, "zlib error (%d)", r);
LOG(INFO) << "zlib error (" << r << ")";
goto error;
}
} while (zs->avail_out == 0);

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

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

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

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

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

@ -21,9 +21,9 @@
#include <utility>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.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) {
break;
}
gpr_log(GPR_INFO,
"gpr_now(GPR_CLOCK_MONOTONIC) returns a very small number: "
"sleeping for 100ms");
LOG(INFO) << "gpr_now(GPR_CLOCK_MONOTONIC) returns a very small number: "
"sleeping for 100ms";
gpr_sleep_until(gpr_time_add(now, gpr_time_from_millis(100, GPR_TIMESPAN)));
}

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

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

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

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

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

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

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

@ -20,14 +20,13 @@
#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/security/credentials/alts/check_gcp_environment.h"
bool grpc_alts_is_running_on_gcp() {
gpr_log(GPR_INFO,
"ALTS: Platforms other than Linux and Windows are not supported");
LOG(INFO) << "ALTS: Platforms other than Linux and Windows are not supported";
return false;
}

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

@ -18,8 +18,9 @@
#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/log.h>
#include <grpc/support/port_platform.h>
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);
}
// An error occurred.
gpr_log(GPR_ERROR,
"Invalid arguments to grpc_alts_credentials_options_copy()");
LOG(ERROR) << "Invalid arguments to grpc_alts_credentials_options_copy()";
return nullptr;
}

@ -22,8 +22,8 @@
#include <string.h>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.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) {
if (strcmp(arg->key, GRPC_ARG_CHANNEL_CREDENTIALS) != 0) return nullptr;
if (arg->type != GRPC_ARG_POINTER) {
gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
GRPC_ARG_CHANNEL_CREDENTIALS);
LOG(ERROR) << "Invalid type " << arg->type << " for arg "
<< GRPC_ARG_CHANNEL_CREDENTIALS;
return nullptr;
}
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) {
if (strcmp(arg->key, GRPC_SERVER_CREDENTIALS_ARG) != 0) return nullptr;
if (arg->type != GRPC_ARG_POINTER) {
gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
GRPC_SERVER_CREDENTIALS_ARG);
LOG(ERROR) << "Invalid type " << arg->type << " for arg "
<< GRPC_SERVER_CREDENTIALS_ARG;
return nullptr;
}
return static_cast<grpc_server_credentials*>(arg->value.pointer.p);

@ -23,6 +23,7 @@
#include <utility>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/escaping.h"
@ -41,7 +42,6 @@
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/json.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.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) {
auto json = grpc_core::JsonParse(json_string);
if (!json.ok()) {
gpr_log(GPR_ERROR,
"External account credentials creation failed. Error: %s.",
json.status().ToString().c_str());
LOG(ERROR) << "External account credentials creation failed. Error: "
<< json.status();
return nullptr;
}
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)
.release();
if (!error.ok()) {
gpr_log(GPR_ERROR,
"External account credentials creation failed. Error: %s.",
grpc_core::StatusToString(error).c_str());
LOG(ERROR) << "External account credentials creation failed. Error: "
<< grpc_core::StatusToString(error);
return nullptr;
}
return creds;

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

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

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

@ -51,7 +51,6 @@
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/json.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.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);
if (!json.ok()) {
gpr_log(GPR_ERROR, "JSON parse error: %s",
json.status().ToString().c_str());
LOG(ERROR) << "JSON parse error: " << json.status();
return Json(); // JSON null
}
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) {
if (json.type() != Json::Type::kString) {
gpr_log(GPR_ERROR, "Invalid %s field", key);
LOG(ERROR) << "Invalid " << key << " field";
return nullptr;
}
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) {
gpr_timespec result = gpr_time_0(GPR_CLOCK_REALTIME);
if (json.type() != Json::Type::kNumber) {
gpr_log(GPR_ERROR, "Invalid %s field", key);
LOG(ERROR) << "Invalid " << key << " field";
return result;
}
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.
if (grpc_jwt_issuer_email_domain(claims->iss) != nullptr &&
claims->sub != nullptr && strcmp(claims->iss, claims->sub) != 0) {
gpr_log(GPR_ERROR,
"Email issuer (%s) cannot assert another subject (%s) than itself.",
claims->iss, claims->sub);
LOG(ERROR) << "Email issuer (" << claims->iss
<< ") cannot assert another subject (" << claims->sub
<< ") than itself.";
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;
}
if (!audience_ok) {
gpr_log(GPR_ERROR, "Audience mismatch: expected %s and found %s.",
audience == nullptr ? "NULL" : audience,
claims->aud == nullptr ? "NULL" : claims->aud);
LOG(ERROR) << "Audience mismatch: expected "
<< (audience == nullptr ? "NULL" : audience) << " and found "
<< (claims->aud == nullptr ? "NULL" : claims->aud);
return GRPC_JWT_VERIFIER_BAD_AUDIENCE;
}
return GRPC_JWT_VERIFIER_OK;
@ -435,8 +433,7 @@ static Json json_from_http(const grpc_http_response* response) {
return Json(); // JSON null
}
if (response->status != 200) {
gpr_log(GPR_ERROR, "Call to http server failed with error %d.",
response->status);
LOG(ERROR) << "Call to http server failed with error " << response->status;
return Json(); // JSON null
}
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_NE(kty, nullptr);
if (strcmp(kty, "RSA") != 0) {
gpr_log(GPR_ERROR, "Unsupported key type %s.", kty);
LOG(ERROR) << "Unsupported key type " << kty;
goto end;
}
#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);
}
}
gpr_log(GPR_ERROR,
"Could not find matching key in key set for kid=%s and alg=%s",
header_kid, header_alg);
LOG(ERROR) << "Could not find matching key in key set for kid=" << header_kid
<< " and alg=" << header_alg;
return nullptr;
}
@ -700,8 +696,8 @@ static void on_keys_retrieved(void* user_data, grpc_error_handle /*error*/) {
verification_key =
find_verification_key(json, ctx->header->alg, ctx->header->kid);
if (verification_key == nullptr) {
gpr_log(GPR_ERROR, "Could not find verification key with kid %s.",
ctx->header->kid);
LOG(ERROR) << "Could not find verification key with kid "
<< ctx->header->kid;
status = GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR;
goto end;
}
@ -748,7 +744,7 @@ static void on_openid_config_retrieved(void* user_data,
jwks_uri = validate_string_field(*cur, "jwks_uri");
if (jwks_uri == nullptr) goto error;
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;
}
jwks_uri += 8;

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

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

@ -24,7 +24,6 @@
#include "absl/log/log.h"
#include <grpc/grpc_crl_provider.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.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
// file is non-empty.
if (path != nullptr) {
gpr_log(GPR_INFO,
"Enabling TLS session key logging with keys stored at: %s", path);
LOG(INFO) << "Enabling TLS session key logging with keys stored at: "
<< path;
} else {
LOG(INFO) << "Disabling TLS session key logging";
}

@ -35,14 +35,13 @@
#include <openssl/x509.h>
#include "absl/container/flat_hash_map.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.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/gprpp/directory_reader.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;
if (!inserted) {
gpr_log(GPR_ERROR,
"StaticCrlProvider received multiple CRLs with the same issuer. "
"The first one in the span will be used.");
LOG(ERROR) << "StaticCrlProvider received multiple CRLs with the same "
"issuer. The first one in the span will be used.";
}
}
StaticCrlProvider provider = StaticCrlProvider(std::move(crl_map));

@ -28,7 +28,6 @@
#include <grpc/grpc.h>
#include <grpc/grpc_security_constants.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/channel/channel_args.h"
@ -63,9 +62,8 @@ bool CredentialOptionSanityCheck(grpc_tls_credentials_options* options,
return false;
}
if (!options->crl_directory().empty() && options->crl_provider() != nullptr) {
gpr_log(GPR_ERROR,
"Setting crl_directory and crl_provider not supported. Using the "
"crl_provider.");
LOG(ERROR) << "Setting crl_directory and crl_provider not supported. Using "
"the crl_provider.";
// TODO(gtcooke94) - Maybe return false here. Right now object lifetime of
// this options struct is leaky if false is returned and represents a more
// 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.
if (is_client && options->cert_request_type() !=
GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE) {
gpr_log(GPR_ERROR,
"Client's credentials options should not set cert_request_type.");
LOG(ERROR)
<< "Client's credentials options should not set cert_request_type.";
}
if (!is_client && !options->verify_server_cert()) {
gpr_log(GPR_ERROR,
"Server's credentials options should not set verify_server_cert.");
LOG(ERROR)
<< "Server's credentials options should not set verify_server_cert.";
}
// In the following conditions, there could be severe security issues.
if (is_client && options->certificate_verifier() == nullptr) {
// 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
// implement an external verifier instead.
gpr_log(GPR_INFO,
"No verifier specified on the client side. Using default hostname "
"verifier");
LOG(INFO) << "No verifier specified on the client side. Using default "
"hostname verifier";
options->set_certificate_verifier(
grpc_core::MakeRefCounted<grpc_core::HostNameCertificateVerifier>());
}

@ -22,11 +22,11 @@
#include <algorithm>
#include "absl/log/log.h"
#include "absl/strings/ascii.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
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);
const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
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 "";
}
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 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);
}
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;
}

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

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

@ -35,7 +35,6 @@
#include "absl/log/log.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/config/config_vars.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,
file_entry_name);
if (path_len == 0) {
gpr_log(GPR_ERROR, "failed to get absolute path for file: %s",
file_entry_name);
LOG(ERROR) << "failed to get absolute path for file: " << file_entry_name;
}
}
}

@ -24,6 +24,7 @@
#include <utility>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/match.h"
@ -33,7 +34,6 @@
#include <grpc/grpc.h>
#include <grpc/grpc_security_constants.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.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::StatusOr<grpc_core::URI> uri = grpc_core::URI::Parse(local_addr);
if (!uri.ok() || !grpc_parse_uri(*uri, &resolved_addr)) {
gpr_log(GPR_ERROR, "Could not parse endpoint address: %s",
std::string(local_addr.data(), local_addr.size()).c_str());
LOG(ERROR) << "Could not parse endpoint address: " << local_addr;
} else {
grpc_resolved_address addr_normalized;
grpc_resolved_address* addr =
@ -269,9 +268,8 @@ grpc_local_channel_security_connector_create(
grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
const grpc_core::ChannelArgs& args, const char* target_name) {
if (channel_creds == nullptr || target_name == nullptr) {
gpr_log(
GPR_ERROR,
"Invalid arguments to grpc_local_channel_security_connector_create()");
LOG(ERROR) << "Invalid arguments to "
"grpc_local_channel_security_connector_create()";
return nullptr;
}
// 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 &&
!absl::StartsWith(server_uri_str, GRPC_UDS_URI_PATTERN) &&
!absl::StartsWith(server_uri_str, GRPC_ABSTRACT_UDS_URI_PATTERN)) {
gpr_log(GPR_ERROR,
"Invalid UDS target name to "
"grpc_local_channel_security_connector_create()");
LOG(ERROR) << "Invalid UDS target name to "
"grpc_local_channel_security_connector_create()";
return nullptr;
}
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_core::RefCountedPtr<grpc_server_credentials> server_creds) {
if (server_creds == nullptr) {
gpr_log(
GPR_ERROR,
"Invalid arguments to grpc_local_server_security_connector_create()");
LOG(ERROR)
<< "Invalid arguments to grpc_local_server_security_connector_create()";
return nullptr;
}
return grpc_core::MakeRefCounted<grpc_local_server_security_connector>(

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

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

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

@ -33,7 +33,6 @@
#include <grpc/grpc_security.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.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,
/*ssl_bio_buf_size=*/0, &handshaker);
if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
tsi_result_to_string(result));
LOG(ERROR) << "Handshaker creation failed with error "
<< tsi_result_to_string(result);
}
}
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* secure_peer_name) {
if (secure_peer_name != nullptr && pem_root_certs == nullptr) {
gpr_log(GPR_ERROR,
"Cannot assert a secure peer name without a trust root.");
LOG(ERROR) << "Cannot assert a secure peer name without a trust root.";
return nullptr;
}
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));
tsi_result result = c->InitHandshakerFactory(pem_root_certs, root_store);
if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
tsi_result_to_string(result));
LOG(ERROR) << "Handshaker factory creation failed with "
<< tsi_result_to_string(result);
return nullptr;
}
return c;

Loading…
Cancel
Save