Matt Spinler | f61f292 | 2020-06-23 11:32:49 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <fstream> |
Patrick Williams | a06b4c6 | 2024-11-21 11:43:39 -0500 | [diff] [blame] | 4 | #include <map> |
Matt Spinler | f61f292 | 2020-06-23 11:32:49 -0500 | [diff] [blame] | 5 | #include <optional> |
| 6 | #include <string> |
Patrick Williams | a06b4c6 | 2024-11-21 11:43:39 -0500 | [diff] [blame] | 7 | #include <vector> |
Matt Spinler | f61f292 | 2020-06-23 11:32:49 -0500 | [diff] [blame] | 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 | |
Matt Spinler | 271d143 | 2023-01-18 13:58:05 -0600 | [diff] [blame] | 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 | |
Patrick Williams | a06b4c6 | 2024-11-21 11:43:39 -0500 | [diff] [blame] | 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 | |
Matt Spinler | f61f292 | 2020-06-23 11:32:49 -0500 | [diff] [blame] | 47 | } // namespace phosphor::logging::util |