1 #pragma once 2 3 #include <fstream> 4 #include <map> 5 #include <optional> 6 #include <string> 7 #include <vector> 8 9 namespace phosphor::logging::util 10 { 11 12 /** 13 * @brief Return a value found in the /etc/os-release file 14 * 15 * @param[in] key - The key name, like "VERSION" 16 * 17 * @return std::optional<std::string> - The value 18 */ 19 std::optional<std::string> getOSReleaseValue(const std::string& key); 20 21 /** 22 * @brief Synchronize unwritten journal messages to disk. 23 * @details This is the same implementation as the systemd command 24 * "journalctl --sync". 25 */ 26 void journalSync(); 27 28 namespace additional_data 29 { 30 /** @brief Pull out metadata name and value from the string 31 * <metadata name>=<metadata value> 32 * @param [in] data - metadata key=value entries 33 * @return map of metadata name:value 34 */ 35 auto parse(const std::vector<std::string>& data) 36 -> std::map<std::string, std::string>; 37 /** @brief Combine the metadata keys and values from the map 38 * into a vector of strings that look like: 39 * "<metadata name>=<metadata value>" 40 * @param [in] data - metadata key:value map 41 * @return vector of "key=value" strings 42 */ 43 auto combine(const std::map<std::string, std::string>& data) 44 -> std::vector<std::string>; 45 } // namespace additional_data 46 47 } // namespace phosphor::logging::util 48