blob: f431b4c1a21aa0e9014d10103ffd755de7464aca [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,
12 std::string_view output_folder);
13
14 private:
15 std::unique_ptr<aos::EventLoop> event_loop_;
16 std::unique_ptr<aos::logger::LogNamer> namer_;
17 std::unique_ptr<aos::logger::Logger> logger_;
18};
19
20// Creates a logger for each of the specified nodes. This makes it so that you
21// can easily setup some number of loggers in simulation or log replay without
22// needing to redo all the boilerplate every time.
23std::vector<std::unique_ptr<LoggerState>> MakeLoggersForNodes(
24 aos::SimulatedEventLoopFactory *factory,
25 const std::vector<std::string> &nodes_to_log,
26 std::string_view output_folder);
27
28// Creates loggers for all of the nodes.
29std::vector<std::unique_ptr<LoggerState>> MakeLoggersForAllNodes(
30 aos::SimulatedEventLoopFactory *factory, std::string_view output_folder);
31
32} // namespace aos::util
33#endif // AOS_UTIL_SIMULATION_LOGGER_H_