blob: 3de63f27b4db9d2264ccd571c91a1867da79a99c [file] [log] [blame]
Andrew Geissler693eaed2019-08-02 14:12:28 -05001#pragma once
2
Andrew Geisslere426b582020-05-28 12:40:55 -05003#include <nlohmann/json.hpp>
4
Andrew Geissler693eaed2019-08-02 14:12:28 -05005#include <map>
6#include <string>
7#include <vector>
8
Andrew Geissler693eaed2019-08-02 14:12:28 -05009/** @brief Stores the error to log if errors to monitor is found */
10struct targetEntry
11{
12 std::string errorToLog;
13 std::vector<std::string> errorsToMonitor;
14};
15
16/** @brief A map of the systemd target to its corresponding targetEntry*/
17using TargetErrorData = std::map<std::string, targetEntry>;
18
19using json = nlohmann::json;
20
21extern bool gVerbose;
22
23/** @brief Parse input json files
24 *
25 * Will return the parsed data in the TargetErrorData object
26 *
27 * @note This function will throw exceptions for an invalid json file
28 * @note See phosphor-target-monitor-default.json for example of json file
29 * format
30 *
31 * @param[in] filePaths - The file(s) to parse
32 *
33 * @return Map of target to error log relationships
34 */
35TargetErrorData parseFiles(const std::vector<std::string>& filePaths);