1693eaed0SAndrew Geissler #pragma once 2693eaed0SAndrew Geissler 3*e426b589SAndrew Geissler #include <nlohmann/json.hpp> 4*e426b589SAndrew Geissler 5693eaed0SAndrew Geissler #include <map> 6693eaed0SAndrew Geissler #include <string> 7693eaed0SAndrew Geissler #include <vector> 8693eaed0SAndrew Geissler 9693eaed0SAndrew Geissler /** @brief Stores the error to log if errors to monitor is found */ 10693eaed0SAndrew Geissler struct targetEntry 11693eaed0SAndrew Geissler { 12693eaed0SAndrew Geissler std::string errorToLog; 13693eaed0SAndrew Geissler std::vector<std::string> errorsToMonitor; 14693eaed0SAndrew Geissler }; 15693eaed0SAndrew Geissler 16693eaed0SAndrew Geissler /** @brief A map of the systemd target to its corresponding targetEntry*/ 17693eaed0SAndrew Geissler using TargetErrorData = std::map<std::string, targetEntry>; 18693eaed0SAndrew Geissler 19693eaed0SAndrew Geissler using json = nlohmann::json; 20693eaed0SAndrew Geissler 21693eaed0SAndrew Geissler extern bool gVerbose; 22693eaed0SAndrew Geissler 23693eaed0SAndrew Geissler /** @brief Parse input json files 24693eaed0SAndrew Geissler * 25693eaed0SAndrew Geissler * Will return the parsed data in the TargetErrorData object 26693eaed0SAndrew Geissler * 27693eaed0SAndrew Geissler * @note This function will throw exceptions for an invalid json file 28693eaed0SAndrew Geissler * @note See phosphor-target-monitor-default.json for example of json file 29693eaed0SAndrew Geissler * format 30693eaed0SAndrew Geissler * 31693eaed0SAndrew Geissler * @param[in] filePaths - The file(s) to parse 32693eaed0SAndrew Geissler * 33693eaed0SAndrew Geissler * @return Map of target to error log relationships 34693eaed0SAndrew Geissler */ 35693eaed0SAndrew Geissler TargetErrorData parseFiles(const std::vector<std::string>& filePaths); 36