1 #pragma once 2 3 #include "xyz/openbmc_project/Logging/Entry/server.hpp" 4 #include "xyz/openbmc_project/Object/Delete/server.hpp" 5 #include "xyz/openbmc_project/Software/Version/server.hpp" 6 7 #include <sdbusplus/bus.hpp> 8 #include <sdbusplus/server/object.hpp> 9 #include <xyz/openbmc_project/Association/Definitions/server.hpp> 10 11 namespace phosphor 12 { 13 namespace logging 14 { 15 16 using EntryIfaces = sdbusplus::server::object::object< 17 sdbusplus::xyz::openbmc_project::Logging::server::Entry, 18 sdbusplus::xyz::openbmc_project::Object::server::Delete, 19 sdbusplus::xyz::openbmc_project::Association::server::Definitions, 20 sdbusplus::xyz::openbmc_project::Software::server::Version>; 21 22 using AssociationList = 23 std::vector<std::tuple<std::string, std::string, std::string>>; 24 25 namespace internal 26 { 27 class Manager; 28 } 29 30 /** @class Entry 31 * @brief OpenBMC logging entry implementation. 32 * @details A concrete implementation for the 33 * xyz.openbmc_project.Logging.Entry and 34 * xyz.openbmc_project.Associations.Definitions DBus APIs. 35 */ 36 class Entry : public EntryIfaces 37 { 38 public: 39 Entry() = delete; 40 Entry(const Entry&) = delete; 41 Entry& operator=(const Entry&) = delete; 42 Entry(Entry&&) = delete; 43 Entry& operator=(Entry&&) = delete; 44 virtual ~Entry() = default; 45 46 /** @brief Constructor to put object onto bus at a dbus path. 47 * Defer signal registration (pass true for deferSignal to the 48 * base class) until after the properties are set. 49 * @param[in] bus - Bus to attach to. 50 * @param[in] path - Path to attach at. 51 * @param[in] idErr - The error entry id. 52 * @param[in] timestampErr - The commit timestamp. 53 * @param[in] severityErr - The severity of the error. 54 * @param[in] msgErr - The message of the error. 55 * @param[in] additionalDataErr - The error metadata. 56 * @param[in] objects - The list of associations. 57 * @param[in] fwVersion - The BMC code version. 58 * @param[in] parent - The error's parent. 59 */ 60 Entry(sdbusplus::bus::bus& bus, const std::string& path, uint32_t idErr, 61 uint64_t timestampErr, Level severityErr, std::string&& msgErr, 62 std::vector<std::string>&& additionalDataErr, 63 AssociationList&& objects, const std::string& fwVersion, 64 internal::Manager& parent) : 65 EntryIfaces(bus, path.c_str(), true), 66 parent(parent) 67 { 68 id(idErr); 69 severity(severityErr); 70 timestamp(timestampErr); 71 updateTimestamp(timestampErr); 72 message(std::move(msgErr)); 73 additionalData(std::move(additionalDataErr)); 74 associations(std::move(objects)); 75 // Store a copy of associations in case we need to recreate 76 assocs = associations(); 77 sdbusplus::xyz::openbmc_project::Logging::server::Entry::resolved( 78 false); 79 80 version(fwVersion); 81 purpose(VersionPurpose::BMC); 82 83 // Emit deferred signal. 84 this->emit_object_added(); 85 }; 86 87 /** @brief Constructor that puts an "empty" error object on the bus, 88 * with only the id property populated. Rest of the properties 89 * to be set by the caller. Caller should emit the added signal. 90 * @param[in] bus - Bus to attach to. 91 * @param[in] path - Path to attach at. 92 * @param[in] id - The error entry id. 93 * @param[in] parent - The error's parent. 94 */ 95 Entry(sdbusplus::bus::bus& bus, const std::string& path, uint32_t entryId, 96 internal::Manager& parent) : 97 EntryIfaces(bus, path.c_str(), true), 98 parent(parent) 99 { 100 id(entryId); 101 }; 102 103 /** @brief Set resolution status of the error. 104 * @param[in] value - boolean indicating resolution 105 * status (true = resolved) 106 * @returns value of 'Resolved' property 107 */ 108 bool resolved(bool value) override; 109 110 using sdbusplus::xyz::openbmc_project::Logging::server::Entry::resolved; 111 112 /** @brief Delete this d-bus object. 113 */ 114 void delete_() override; 115 116 /** @brief Severity level to check in cap. 117 * @details Errors with severity lesser than this will be 118 * considered as low priority and maximum ERROR_INFO_CAP 119 * number errors of this category will be captured. 120 */ 121 static constexpr auto sevLowerLimit = Entry::Level::Informational; 122 123 private: 124 /** @brief This entry's associations */ 125 AssociationList assocs = {}; 126 127 /** @brief This entry's parent */ 128 internal::Manager& parent; 129 }; 130 131 } // namespace logging 132 } // namespace phosphor 133