1 #pragma once
2 
3 #include <sdbusplus/bus.hpp>
4 #include "elog_entry.hpp"
5 #include "xyz/openbmc_project/Logging/Internal/Manager/server.hpp"
6 
7 namespace phosphor
8 {
9 namespace logging
10 {
11 namespace details
12 {
13 
14 template <typename T>
15 using ServerObject = typename sdbusplus::server::object::object<T>;
16 
17 using 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  */
27 class Manager : public details::ServerObject<details::ManagerIface>
28 {
29     public:
30         Manager() = delete;
31         Manager(const Manager&) = delete;
32         Manager& operator=(const Manager&) = delete;
33         Manager(Manager&&) = delete;
34         Manager& operator=(Manager&&) = delete;
35         virtual ~Manager() = default;
36 
37         /** @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.
40          */
41         Manager(sdbusplus::bus::bus& bus, const char* objPath) :
42                 details::ServerObject<details::ManagerIface>(bus, objPath),
43                 busLog(bus),
44                 entryId(0) {};
45 
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;
57 
58 
59     private:
60         /** @brief Call metadata handler(s), if any. Handlers may create
61          *         associations.
62          *  @param[in] errorName - name of the error
63          *  @param[in] additionalData - list of metadata (in key=value format)
64          *  @param[out] objects - list of error's association objects
65          */
66         void processMetadata(const std::string& errorName,
67                              const std::vector<std::string>& additionalData,
68                              AssociationList& objects) const;
69 
70         /** @brief Persistent sdbusplus DBus bus connection. */
71         sdbusplus::bus::bus& busLog;
72 
73         /** @brief Persistent map of Entry dbus objects and their ID */
74         std::map<uint32_t, std::unique_ptr<Entry>> entries;
75 
76         /** @brief Id of last error log entry */
77         uint32_t entryId;
78 };
79 
80 } // namespace logging
81 } // namespace phosphor
82