Factor out JsonOptions into a struct
Change-Id: I2441069e86ea2eb95d8e1952be7c2a7a43036c74
diff --git a/aos/events/event_loop_param_test.cc b/aos/events/event_loop_param_test.cc
index d0ca3ee..dc7c5d0 100644
--- a/aos/events/event_loop_param_test.cc
+++ b/aos/events/event_loop_param_test.cc
@@ -767,7 +767,7 @@
// Confirm that we have the right number of reports, and the contents are
// sane.
- VLOG(1) << FlatbufferToJson(report, true);
+ VLOG(1) << FlatbufferToJson(report, {.multi_line = true});
EXPECT_EQ(report.message().name()->string_view(), "primary");
@@ -1181,7 +1181,7 @@
}
}
- VLOG(1) << FlatbufferToJson(report, true);
+ VLOG(1) << FlatbufferToJson(report, {.multi_line = true});
EXPECT_EQ(report.message().name()->string_view(), "primary");
@@ -1245,7 +1245,7 @@
}
}
- LOG(INFO) << FlatbufferToJson(primary_report, true);
+ LOG(INFO) << FlatbufferToJson(primary_report, {.multi_line = true});
EXPECT_EQ(primary_report.message().name()->string_view(), "primary");
@@ -1327,7 +1327,7 @@
}
// Check the watcher report.
- VLOG(1) << FlatbufferToJson(primary_report, true);
+ VLOG(1) << FlatbufferToJson(primary_report, {.multi_line = true});
EXPECT_EQ(primary_report.message().name()->string_view(), "primary");
@@ -1397,7 +1397,7 @@
}
}
- VLOG(1) << FlatbufferToJson(primary_report, true);
+ VLOG(1) << FlatbufferToJson(primary_report, {.multi_line = true});
EXPECT_EQ(primary_report.message().name()->string_view(), "primary");
diff --git a/aos/events/logging/log_cat.cc b/aos/events/logging/log_cat.cc
index a1696eb..d3095cb 100644
--- a/aos/events/logging/log_cat.cc
+++ b/aos/events/logging/log_cat.cc
@@ -45,7 +45,7 @@
<< aos::FlatbufferToJson(
channel->schema(),
static_cast<const uint8_t *>(context.data),
- FLAGS_max_vector_size)
+ {false, static_cast<size_t>(FLAGS_max_vector_size)})
<< std::endl;
} else {
std::cout << node_name << context.realtime_event_time << " ("
@@ -55,7 +55,7 @@
<< aos::FlatbufferToJson(
channel->schema(),
static_cast<const uint8_t *>(context.data),
- FLAGS_max_vector_size)
+ {false, static_cast<size_t>(FLAGS_max_vector_size)})
<< std::endl;
}
}
@@ -93,16 +93,20 @@
if (FLAGS_format_raw && message.value().message().data() != nullptr) {
std::cout << aos::configuration::StrippedChannelToString(channel) << " "
- << aos::FlatbufferToJson(message.value(), false, 4) << ": "
+ << aos::FlatbufferToJson(
+ message.value(),
+ {.multi_line = false, .max_vector_size = 4})
+ << ": "
<< aos::FlatbufferToJson(
channel->schema(),
message.value().message().data()->data(),
- FLAGS_max_vector_size)
+ {false, static_cast<size_t>(FLAGS_max_vector_size)})
<< std::endl;
} else {
std::cout << aos::configuration::StrippedChannelToString(channel) << " "
- << aos::FlatbufferToJson(message.value(), false,
- FLAGS_max_vector_size)
+ << aos::FlatbufferToJson(
+ message.value(),
+ {false, static_cast<size_t>(FLAGS_max_vector_size)})
<< std::endl;
}
}
diff --git a/aos/events/logging/log_edit.cc b/aos/events/logging/log_edit.cc
index ff263f8..0dca904 100644
--- a/aos/events/logging/log_edit.cc
+++ b/aos/events/logging/log_edit.cc
@@ -18,8 +18,7 @@
"If provided, this is the path to the JSON with the log file header.");
int main(int argc, char **argv) {
- gflags::SetUsageMessage(
- R"(This tool lets us manipulate log files.)");
+ gflags::SetUsageMessage(R"(This tool lets us manipulate log files.)");
aos::InitGoogle(&argc, &argv);
if (!FLAGS_header.empty()) {
@@ -53,7 +52,8 @@
} else {
aos::logger::MessageReader reader(FLAGS_logfile);
aos::util::WriteStringToFileOrDie(
- FLAGS_header, aos::FlatbufferToJson(reader.log_file_header(), true));
+ FLAGS_header, aos::FlatbufferToJson(reader.log_file_header(),
+ {.multi_line = true}));
}
}
diff --git a/aos/events/simulated_event_loop_test.cc b/aos/events/simulated_event_loop_test.cc
index 0b5dbec..513dc1b 100644
--- a/aos/events/simulated_event_loop_test.cc
+++ b/aos/events/simulated_event_loop_test.cc
@@ -72,9 +72,8 @@
[&counter]() { counter += 1; });
scheduler_scheduler.Run();
EXPECT_EQ(counter, 1);
- auto token =
- scheduler.Schedule(monotonic_clock::epoch() + chrono::seconds(2),
- [&counter]() { counter += 1; });
+ auto token = scheduler.Schedule(monotonic_clock::epoch() + chrono::seconds(2),
+ [&counter]() { counter += 1; });
scheduler.Deschedule(token);
scheduler_scheduler.Run();
EXPECT_EQ(counter, 1);
@@ -189,7 +188,7 @@
}
// Check the watcher report.
- VLOG(1) << FlatbufferToJson(primary_report, true);
+ VLOG(1) << FlatbufferToJson(primary_report, {.multi_line = true});
EXPECT_EQ(primary_report.message().name()->string_view(), "primary");