blob: 43070ff7916467085f7a1cf4b3824aa9e07c7b3a [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 Kobylakdf995fa2017-01-08 15:14:02 -06004#include "elog_entry.hpp"
Adriana Kobylak8f7941e2016-11-14 14:46:23 -06005#include "xyz/openbmc_project/Logging/Internal/Manager/server.hpp"
6
7namespace phosphor
8{
9namespace logging
10{
11namespace details
12{
13
14template <typename T>
15using ServerObject = typename sdbusplus::server::object::object<T>;
16
17using ManagerIface =
18 sdbusplus::xyz::openbmc_project::Logging::Internal::server::Manager;
19
20} // namespace details
21
22/** @class Manager
23 * @brief OpenBMC logging manager implementation.
24 * @details A concrete implementation for the
25 * xyz.openbmc_project.Logging.Internal.Manager DBus API.
26 */
Adriana Kobylakf477fe22017-01-06 11:56:41 -060027class Manager : public details::ServerObject<details::ManagerIface>
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060028{
29 public:
30 Manager() = delete;
31 Manager(const Manager&) = delete;
32 Manager& operator=(const Manager&) = delete;
Adriana Kobylakf477fe22017-01-06 11:56:41 -060033 Manager(Manager&&) = delete;
34 Manager& operator=(Manager&&) = delete;
35 virtual ~Manager() = default;
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060036
Adriana Kobylakf477fe22017-01-06 11:56:41 -060037 /** @brief Constructor to put object onto bus at a dbus path.
38 * @param[in] bus - Bus to attach to.
39 * @param[in] path - Path to attach at.
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060040 */
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060041 Manager(sdbusplus::bus::bus& bus, const char* objPath) :
42 details::ServerObject<details::ManagerIface>(bus, objPath),
43 busLog(bus),
44 entryId(0) {};
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060045
46 /*
47 * @fn commit()
48 * @brief sd_bus Commit method implementation callback.
49 * @details Create an error/event log based on transaction id and
50 * error message.
51 * @param[in] transactionId - Unique identifier of the journal entries
52 * to be committed.
53 * @param[in] errMsg - The error exception message associated with the
54 * error log to be committed.
55 */
56 void commit(uint64_t transactionId, std::string errMsg) override;
Adriana Kobylakdf995fa2017-01-08 15:14:02 -060057
58
59 private:
60 /** @brief Persistent sdbusplus DBus bus connection. */
61 sdbusplus::bus::bus& busLog;
62
63 /** @brief Persistent map of Entry dbus objects and their ID */
64 std::map<uint32_t, std::unique_ptr<Entry>> entries;
Adriana Kobylak4ea7f312017-01-10 12:52:34 -060065
66 /** @brief Id of last error log entry */
67 uint32_t entryId;
Adriana Kobylak8f7941e2016-11-14 14:46:23 -060068};
69
70} // namespace logging
71} // namespace phosphor