blob: 730f63ef2292241716e3a0c35d2052c9df6983d9 [file] [log] [blame]
Adriana Kobylak8f7941e2016-11-14 14:46:23 -06001#pragma once
2
Adriana Kobylakf477fe22017-01-06 11:56:41 -06003#include <sdbusplus/bus.hpp>
Adriana Kobylakd722b3a2017-02-28 12:10:44 -06004#include <phosphor-logging/log.hpp>
Adriana Kobylakdf995fa2017-01-08 15:14:02 -06005#include "elog_entry.hpp"
Adriana Kobylak8f7941e2016-11-14 14:46:23 -06006#include "xyz/openbmc_project/Logging/Internal/Manager/server.hpp"
7
8namespace phosphor
9{
10namespace logging
11{
Adriana Kobylakd722b3a2017-02-28 12:10:44 -060012
13extern const std::map<std::string,std::vector<std::string>> g_errMetaMap;
14extern const std::map<std::string,level> g_errLevelMap;
15
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060016namespace details
17{
18
19template <typename T>
20using ServerObject = typename sdbusplus::server::object::object<T>;
21
22using ManagerIface =
23 sdbusplus::xyz::openbmc_project::Logging::Internal::server::Manager;
24
25} // namespace details
26
27/** @class Manager
28 * @brief OpenBMC logging manager implementation.
29 * @details A concrete implementation for the
30 * xyz.openbmc_project.Logging.Internal.Manager DBus API.
31 */
Adriana Kobylakf477fe22017-01-06 11:56:41 -060032class Manager : public details::ServerObject<details::ManagerIface>
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060033{
34 public:
35 Manager() = delete;
36 Manager(const Manager&) = delete;
37 Manager& operator=(const Manager&) = delete;
Adriana Kobylakf477fe22017-01-06 11:56:41 -060038 Manager(Manager&&) = delete;
39 Manager& operator=(Manager&&) = delete;
40 virtual ~Manager() = default;
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060041
Adriana Kobylakf477fe22017-01-06 11:56:41 -060042 /** @brief Constructor to put object onto bus at a dbus path.
43 * @param[in] bus - Bus to attach to.
44 * @param[in] path - Path to attach at.
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060045 */
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060046 Manager(sdbusplus::bus::bus& bus, const char* objPath) :
47 details::ServerObject<details::ManagerIface>(bus, objPath),
48 busLog(bus),
49 entryId(0) {};
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060050
51 /*
52 * @fn commit()
53 * @brief sd_bus Commit method implementation callback.
54 * @details Create an error/event log based on transaction id and
55 * error message.
56 * @param[in] transactionId - Unique identifier of the journal entries
57 * to be committed.
58 * @param[in] errMsg - The error exception message associated with the
59 * error log to be committed.
60 */
61 void commit(uint64_t transactionId, std::string errMsg) override;
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060062
63
Deepak Kodihalli99a85492017-03-31 06:01:57 -050064 /** @brief Erase specified entry d-bus object
65 *
66 * @param[in] entryId - unique identifier of the entry
67 */
68 void erase(uint32_t entryId);
69
Deepak Kodihalli72654f12017-06-12 04:33:29 -050070 /** @brief Construct error d-bus objects from their persisted
71 * representations.
72 */
73 void restore();
74
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060075 private:
Deepak Kodihallia87c1572017-02-28 07:40:34 -060076 /** @brief Call metadata handler(s), if any. Handlers may create
77 * associations.
78 * @param[in] errorName - name of the error
79 * @param[in] additionalData - list of metadata (in key=value format)
80 * @param[out] objects - list of error's association objects
81 */
82 void processMetadata(const std::string& errorName,
83 const std::vector<std::string>& additionalData,
84 AssociationList& objects) const;
85
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060086 /** @brief Persistent sdbusplus DBus bus connection. */
87 sdbusplus::bus::bus& busLog;
88
89 /** @brief Persistent map of Entry dbus objects and their ID */
90 std::map<uint32_t, std::unique_ptr<Entry>> entries;
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060091
92 /** @brief Id of last error log entry */
93 uint32_t entryId;
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060094};
95
96} // namespace logging
97} // namespace phosphor