Andrew Geissler | 693eaed | 2019-08-02 14:12:28 -0500 | [diff] [blame] | 1 | #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 */ |
| 10 | struct 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*/ |
| 17 | using TargetErrorData = std::map<std::string, targetEntry>; |
| 18 | |
| 19 | using json = nlohmann::json; |
| 20 | |
| 21 | extern 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 | */ |
| 35 | TargetErrorData parseFiles(const std::vector<std::string>& filePaths); |