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