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