[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_log

pull/36694/head
tanvi-jagtap 6 months ago
parent b3e061e086
commit 54ee362e3d
  1. 10
      tools/codegen/core/gen_join.py
  2. 26
      tools/codegen/core/gen_seq.py

@ -70,13 +70,13 @@ struct JoinState<Traits, ${",".join(f"P{i}" for i in range(0,n))}> {
% for i in range(0,n): % for i in range(0,n):
if (!ready.is_set(${i})) { if (!ready.is_set(${i})) {
if (grpc_trace_promise_primitives.enabled()) { if (grpc_trace_promise_primitives.enabled()) {
gpr_log(GPR_DEBUG, "join[%p]: begin poll joint ${i+1}/${n}", this); VLOG(2) << "join[" << this << "]: begin poll joint ${i+1}/${n}";
} }
auto poll = promise${i}(); auto poll = promise${i}();
if (grpc_trace_promise_primitives.enabled()) { if (grpc_trace_promise_primitives.enabled()) {
auto* p = poll.value_if_ready(); auto* p = poll.value_if_ready();
gpr_log(GPR_DEBUG, "join[%p]: joint ${i+1}/${n} %s", this, VLOG(2) << "join[" << this << "]: joint ${i+1}/${n} "
p != nullptr? (Traits::IsOk(*p)? "ready" : "early-error") : "pending"); << (p != nullptr ? (Traits::IsOk(*p)? "ready" : "early-error") : "pending");
} }
if (auto* p = poll.value_if_ready()) { if (auto* p = poll.value_if_ready()) {
if (Traits::IsOk(*p)) { if (Traits::IsOk(*p)) {
@ -88,7 +88,7 @@ struct JoinState<Traits, ${",".join(f"P{i}" for i in range(0,n))}> {
} }
} }
} else if (grpc_trace_promise_primitives.enabled()) { } else if (grpc_trace_promise_primitives.enabled()) {
gpr_log(GPR_DEBUG, "join[%p]: joint ${i+1}/${n} already ready", this); VLOG(2) << "join[" << this << "]: joint ${i+1}/${n} already ready";
} }
% endfor % endfor
if (ready.all()) { if (ready.all()) {
@ -109,12 +109,12 @@ front_matter = """
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "src/core/lib/gprpp/construct_destruct.h" #include "src/core/lib/gprpp/construct_destruct.h"
#include "src/core/lib/promise/detail/promise_like.h" #include "src/core/lib/promise/detail/promise_like.h"
#include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/poll.h"
#include "src/core/lib/gprpp/bitset.h" #include "src/core/lib/gprpp/bitset.h"
#include <grpc/support/log.h>
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>

@ -143,16 +143,18 @@ tail${i}:
% for i in range(0,n-1): % for i in range(0,n-1):
case State::kState${i}: { case State::kState${i}: {
if (grpc_trace_promise_primitives.enabled()) { if (grpc_trace_promise_primitives.enabled()) {
gpr_log(whence.file(), whence.line(), GPR_LOG_SEVERITY_DEBUG, "seq[%p]: begin poll step ${i+1}/${n}", this); VLOG(2).AtLocation(whence.file(), whence.line())
<< "seq[" << this << "]: begin poll step ${i+1}/${n}";
} }
auto result = ${"prior."*(n-1-i)}current_promise(); auto result = ${"prior."*(n-1-i)}current_promise();
PromiseResult${i}* p = result.value_if_ready(); PromiseResult${i}* p = result.value_if_ready();
if (grpc_trace_promise_primitives.enabled()) { if (grpc_trace_promise_primitives.enabled()) {
gpr_log(whence.file(), whence.line(), GPR_LOG_SEVERITY_DEBUG, "seq[%p]: poll step ${i+1}/${n} gets %s", this, VLOG(2).AtLocation(whence.file(), whence.line())
p != nullptr << "seq[" << this << "]: poll step ${i+1}/${n} gets "
<< (p != nullptr
? (PromiseResultTraits${i}::IsOk(*p) ? (PromiseResultTraits${i}::IsOk(*p)
? "ready" ? "ready"
: absl::StrCat("early-error:", PromiseResultTraits${i}::ErrorString(*p)).c_str()) : absl::StrCat("early-error:", PromiseResultTraits${i}::ErrorString(*p)).c_str())
: "pending"); : "pending");
} }
if (p == nullptr) return Pending{}; if (p == nullptr) return Pending{};
@ -170,11 +172,14 @@ tail${i}:
default: default:
case State::kState${n-1}: { case State::kState${n-1}: {
if (grpc_trace_promise_primitives.enabled()) { if (grpc_trace_promise_primitives.enabled()) {
gpr_log(whence.file(), whence.line(), GPR_LOG_SEVERITY_DEBUG, "seq[%p]: begin poll step ${n}/${n}", this); VLOG(2).AtLocation(whence.file(), whence.line())
<< "seq[" << this << "]: begin poll step ${n}/${n}";
} }
auto result = current_promise(); auto result = current_promise();
if (grpc_trace_promise_primitives.enabled()) { if (grpc_trace_promise_primitives.enabled()) {
gpr_log(whence.file(), whence.line(), GPR_LOG_SEVERITY_DEBUG, "seq[%p]: poll step ${n}/${n} gets %s", this, result.ready()? "ready" : "pending"); VLOG(2).AtLocation(whence.file(), whence.line())
<< "seq[" << this << "]: poll step ${n}/${n} gets "
<< (result.ready()? "ready" : "pending");
} }
auto* p = result.value_if_ready(); auto* p = result.value_if_ready();
if (p == nullptr) return Pending{}; if (p == nullptr) return Pending{};
@ -198,11 +203,10 @@ front_matter = """
#include <utility> #include <utility>
#include "absl/log/check.h" #include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
#include <grpc/support/log.h>
#include "src/core/lib/gprpp/construct_destruct.h" #include "src/core/lib/gprpp/construct_destruct.h"
#include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/promise/detail/promise_factory.h" #include "src/core/lib/promise/detail/promise_factory.h"
@ -216,8 +220,8 @@ front_matter = """
// previous step and yield a promise. Note that most of the machinery in // previous step and yield a promise. Note that most of the machinery in
// PromiseFactory exists to make it possible for those promise-factory-like // PromiseFactory exists to make it possible for those promise-factory-like
// objects to be anything that's convenient. // objects to be anything that's convenient.
// Traits defines how we move from one step to the next. Traits sets up the // Traits defines how we move from one step to the next. Traits sets up the
// wrapping and escape handling for the sequence. // wrapping and escape handling for the sequence.
// Promises return wrapped values that the trait can inspect and unwrap before // Promises return wrapped values that the trait can inspect and unwrap before
// passing them to the next element of the sequence. The trait can // passing them to the next element of the sequence. The trait can
// also interpret a wrapped value as an escape value, which terminates // also interpret a wrapped value as an escape value, which terminates

Loading…
Cancel
Save