James Kuszmaul | 4ed5fb1 | 2022-03-22 15:20:04 -0700 | [diff] [blame^] | 1 | #include "aos/events/event_loop_generated.h" |
| 2 | #include "aos/events/logging/log_reader.h" |
| 3 | #include "aos/init.h" |
| 4 | #include "aos/util/mcap_logger.h" |
| 5 | |
| 6 | DEFINE_string(node, "", "Node to replay from the perspective of."); |
| 7 | DEFINE_string(output_path, "/tmp/log.mcap", "Log to output."); |
| 8 | |
| 9 | // Converts an AOS log to an MCAP log that can be fed into Foxglove. To try this |
| 10 | // out, run: |
| 11 | // bazel run -c opt //aos/util:log_to_mcap -- --node NODE_NAME /path/to/logfile |
| 12 | // |
| 13 | // Then navigate to http://studio.foxglove.dev (or spin up your own instance |
| 14 | // locally), and use it to open the file (this doesn't upload the file to |
| 15 | // foxglove's servers or anything). |
| 16 | int main(int argc, char *argv[]) { |
| 17 | aos::InitGoogle(&argc, &argv); |
| 18 | |
| 19 | const std::vector<aos::logger::LogFile> logfiles = |
| 20 | aos::logger::SortParts(aos::logger::FindLogs(argc, argv)); |
| 21 | |
| 22 | aos::logger::LogReader reader(logfiles); |
| 23 | |
| 24 | reader.Register(); |
| 25 | |
| 26 | const aos::Node *node = |
| 27 | aos::configuration::GetNode(reader.configuration(), FLAGS_node); |
| 28 | CHECK_NOTNULL(node); |
| 29 | std::unique_ptr<aos::EventLoop> mcap_event_loop = |
| 30 | reader.event_loop_factory()->MakeEventLoop("mcap", node); |
| 31 | CHECK(!FLAGS_output_path.empty()); |
| 32 | aos::McapLogger relogger(mcap_event_loop.get(), FLAGS_output_path); |
| 33 | reader.event_loop_factory()->Run(); |
| 34 | } |