blob: af43d0229dc495a2b6f190be51373f93151c60d5 [file] [log] [blame]
James Kuszmaule4853542023-05-15 20:35:48 -07001#ifndef AOS_UTIL_SIMULATION_LOGGER_H_
2#define AOS_UTIL_SIMULATION_LOGGER_H_
3#include <string_view>
4
5#include "aos/events/logging/log_writer.h"
6#include "aos/events/simulated_event_loop.h"
7namespace aos::util {
8
9class LoggerState {
10 public:
11 LoggerState(aos::SimulatedEventLoopFactory *factory, const aos::Node *node,
Pallavi Madhukar3076d5c2023-09-09 10:23:26 -070012 std::string_view output_folder,
13 bool do_skip_timing_report = true);
James Kuszmaule4853542023-05-15 20:35:48 -070014
15 private:
16 std::unique_ptr<aos::EventLoop> event_loop_;
17 std::unique_ptr<aos::logger::LogNamer> namer_;
18 std::unique_ptr<aos::logger::Logger> logger_;
19};
20
21// Creates a logger for each of the specified nodes. This makes it so that you
22// can easily setup some number of loggers in simulation or log replay without
23// needing to redo all the boilerplate every time.
24std::vector<std::unique_ptr<LoggerState>> MakeLoggersForNodes(
25 aos::SimulatedEventLoopFactory *factory,
26 const std::vector<std::string> &nodes_to_log,
Pallavi Madhukar3076d5c2023-09-09 10:23:26 -070027 std::string_view output_folder, bool do_skip_timing_report = true);
James Kuszmaule4853542023-05-15 20:35:48 -070028
29// Creates loggers for all of the nodes.
30std::vector<std::unique_ptr<LoggerState>> MakeLoggersForAllNodes(
Pallavi Madhukar3076d5c2023-09-09 10:23:26 -070031 aos::SimulatedEventLoopFactory *factory, std::string_view output_folder,
32 bool do_skip_timing_report = true);
James Kuszmaule4853542023-05-15 20:35:48 -070033
34} // namespace aos::util
35#endif // AOS_UTIL_SIMULATION_LOGGER_H_