blob: 0c8ed072d35e13403175a845a46887e55b7a5e46 [file] [log] [blame]
Naman Guptae7fe3552022-11-23 13:52:03 -08001#ifndef AOS_EVENTS_LOGGING_LOG_READER_UTILS_H_
2#define AOS_EVENTS_LOGGING_LOG_READER_UTILS_H_
3
4#include "aos/events/logging/log_reader.h"
5
6namespace aos::logger {
7
8// Utility struct for returning all channels segregated as senders, watchers and
9// fetchers
10struct ChannelsInLogResult {
11 std::optional<std::vector<aos::ChannelT>> senders;
12 std::optional<std::vector<aos::ChannelT>> watchers;
13 std::optional<std::vector<aos::ChannelT>> fetchers;
14 std::optional<std::vector<aos::ChannelT>>
15 watchers_and_fetchers_without_senders;
16}; // struct ChannelsInLogResult
17
18// A struct to select what kind of channels we want to extract from the log
19struct ChannelsInLogOptions {
20 bool get_senders = false;
21 bool get_watchers = false;
22 bool get_fetchers = false;
23}; // struct ChannelsInLogOptions
24
25// Reads the first ~1 second of timing reports in a logfile and generates a list
26// of all the channels sent on by the specified applications on the specified
27// nodes.
28ChannelsInLogResult ChannelsInLog(
29 const std::vector<aos::logger::LogFile> &log_files,
30 const std::vector<const aos::Node *> &nodes,
31 const std::vector<std::string> &applications,
32 const ChannelsInLogOptions options = ChannelsInLogOptions{true, true,
33 true});
34// Wrapper for channelsinlog but only for sender channels
35std::vector<aos::ChannelT> SenderChannelsInLog(
36 const std::vector<aos::logger::LogFile> &log_files,
37 const std::vector<const aos::Node *> &nodes,
38 const std::vector<std::string> &applications);
39
40// Wrapper for channelsinlog but only for watcher channels
41std::vector<aos::ChannelT> WatcherChannelsInLog(
42 const std::vector<aos::logger::LogFile> &log_files,
43 const std::vector<const aos::Node *> &nodes,
44 const std::vector<std::string> &applications);
45
46// Wrapper for channelsinlog but only for fetcher channels
47std::vector<aos::ChannelT> FetcherChannelsInLog(
48 const std::vector<aos::logger::LogFile> &log_files,
49 const std::vector<const aos::Node *> &nodes,
50 const std::vector<std::string> &applications);
51
52} // namespace aos::logger
53
54#endif // AOS_EVENTS_LOGGING_LOG_READER_UTILS_H_