blob: 405e35c35b61a93ffdbe1da6bfc07c1ad4a213a4 [file] [log] [blame]
Matt Spinlerf61f2922020-06-23 11:32:49 -05001#pragma once
2
3#include <fstream>
Patrick Williamsa06b4c62024-11-21 11:43:39 -05004#include <map>
Matt Spinlerf61f2922020-06-23 11:32:49 -05005#include <optional>
6#include <string>
Patrick Williamsa06b4c62024-11-21 11:43:39 -05007#include <vector>
Matt Spinlerf61f2922020-06-23 11:32:49 -05008
9namespace 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 */
19std::optional<std::string> getOSReleaseValue(const std::string& key);
20
Matt Spinler271d1432023-01-18 13:58:05 -060021/**
22 * @brief Synchronize unwritten journal messages to disk.
23 * @details This is the same implementation as the systemd command
24 * "journalctl --sync".
25 */
26void journalSync();
27
Patrick Williamsa06b4c62024-11-21 11:43:39 -050028namespace 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 */
35auto 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 */
43auto combine(const std::map<std::string, std::string>& data)
44 -> std::vector<std::string>;
45} // namespace additional_data
46
Matt Spinlerf61f2922020-06-23 11:32:49 -050047} // namespace phosphor::logging::util