blob: fbe3814d42966059587813946367abed80f6d6ae [file] [log] [blame]
Andrew Geissler693eaed2019-08-02 14:12:28 -05001#pragma once
2
3#include <map>
4#include <string>
5#include <vector>
6
7#include <nlohmann/json.hpp>
8
9/** @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);