Skip to content

Commit

Permalink
VLOG sends/receives in ChannelTraceRecorder.
Browse files Browse the repository at this point in the history
When setting trace_channels as an EvaluatorOption, this allows for useful debugging in C++ tests using a JIT wrapper.

PiperOrigin-RevId: 688791714
  • Loading branch information
mikex-oss authored and copybara-github committed Oct 23, 2024
1 parent b55d18f commit cb2829a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions xls/interpreter/proc_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,22 @@ class ChannelTraceRecorder : public ChannelQueueCallback {

void ReadValue(ChannelInstance* channel_instance,
const Value& value) override {
runtime_->AddTraceMessage(TraceMessage{
.message = absl::StrFormat("Received data on channel `%s`: %s",
channel_instance->ToString(),
value.ToString(format_preference_)),
.verbosity = 0});
std::string message = absl::StrFormat("Received data on channel `%s`: %s",
channel_instance->ToString(),
value.ToString(format_preference_));
VLOG(3) << message;
runtime_->AddTraceMessage(
TraceMessage{.message = std::move(message), .verbosity = 0});
}

void WriteValue(ChannelInstance* channel_instance,
const Value& value) override {
runtime_->AddTraceMessage(TraceMessage{
.message = absl::StrFormat("Sent data on channel `%s`: %s",
channel_instance->ToString(),
value.ToString(format_preference_)),
.verbosity = 0});
std::string message = absl::StrFormat("Sent data on channel `%s`: %s",
channel_instance->ToString(),
value.ToString(format_preference_));
VLOG(3) << message;
runtime_->AddTraceMessage(
TraceMessage{.message = std::move(message), .verbosity = 0});
}

private:
Expand Down

0 comments on commit cb2829a

Please sign in to comment.