Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Andrew Geissler | 6a0ef6f | 2020-04-06 15:06:31 -0500 | [diff] [blame] | 3 | #include "elog_block.hpp" |
Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 4 | #include "elog_entry.hpp" |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 5 | #include "xyz/openbmc_project/Collection/DeleteAll/server.hpp" |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 6 | #include "xyz/openbmc_project/Logging/Create/server.hpp" |
| 7 | #include "xyz/openbmc_project/Logging/Entry/server.hpp" |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 8 | #include "xyz/openbmc_project/Logging/Internal/Manager/server.hpp" |
BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame] | 9 | #include "xyz/openbmc_project/Logging/error.hpp" |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 10 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 11 | #include <phosphor-logging/log.hpp> |
| 12 | #include <sdbusplus/bus.hpp> |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 13 | |
Patrick Williams | 2544b41 | 2022-10-04 08:41:06 -0500 | [diff] [blame] | 14 | #include <list> |
| 15 | |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 16 | namespace phosphor |
| 17 | { |
| 18 | namespace logging |
| 19 | { |
Adriana Kobylak | d722b3a | 2017-02-28 12:10:44 -0600 | [diff] [blame] | 20 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 21 | extern const std::map<std::string, std::vector<std::string>> g_errMetaMap; |
| 22 | extern const std::map<std::string, level> g_errLevelMap; |
Adriana Kobylak | d722b3a | 2017-02-28 12:10:44 -0600 | [diff] [blame] | 23 | |
Willy Tu | 6ddbf69 | 2023-09-05 10:54:16 -0700 | [diff] [blame] | 24 | using CreateIface = sdbusplus::server::xyz::openbmc_project::logging::Create; |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 25 | using DeleteAllIface = |
Willy Tu | 6ddbf69 | 2023-09-05 10:54:16 -0700 | [diff] [blame] | 26 | sdbusplus::server::xyz::openbmc_project::collection::DeleteAll; |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 27 | |
BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame] | 28 | using Severity = sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level; |
| 29 | using LogsCleared = |
| 30 | sdbusplus::xyz::openbmc_project::Logging::Error::LogsCleared; |
| 31 | |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 32 | namespace details |
| 33 | { |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 34 | template <typename... T> |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 35 | using ServerObject = typename sdbusplus::server::object_t<T...>; |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 36 | |
| 37 | using ManagerIface = |
Willy Tu | 6ddbf69 | 2023-09-05 10:54:16 -0700 | [diff] [blame] | 38 | sdbusplus::server::xyz::openbmc_project::logging::internal::Manager; |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 39 | |
| 40 | } // namespace details |
| 41 | |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 42 | constexpr size_t ffdcFormatPos = 0; |
| 43 | constexpr size_t ffdcSubtypePos = 1; |
| 44 | constexpr size_t ffdcVersionPos = 2; |
| 45 | constexpr size_t ffdcFDPos = 3; |
| 46 | |
| 47 | using FFDCEntry = std::tuple<CreateIface::FFDCFormat, uint8_t, uint8_t, |
| 48 | sdbusplus::message::unix_fd>; |
| 49 | |
| 50 | using FFDCEntries = std::vector<FFDCEntry>; |
| 51 | |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 52 | namespace internal |
| 53 | { |
| 54 | |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 55 | /** @class Manager |
| 56 | * @brief OpenBMC logging manager implementation. |
| 57 | * @details A concrete implementation for the |
| 58 | * xyz.openbmc_project.Logging.Internal.Manager DBus API. |
| 59 | */ |
Adriana Kobylak | f477fe2 | 2017-01-06 11:56:41 -0600 | [diff] [blame] | 60 | class Manager : public details::ServerObject<details::ManagerIface> |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 61 | { |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 62 | public: |
| 63 | Manager() = delete; |
| 64 | Manager(const Manager&) = delete; |
| 65 | Manager& operator=(const Manager&) = delete; |
| 66 | Manager(Manager&&) = delete; |
| 67 | Manager& operator=(Manager&&) = delete; |
| 68 | virtual ~Manager() = default; |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 69 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 70 | /** @brief Constructor to put object onto bus at a dbus path. |
| 71 | * @param[in] bus - Bus to attach to. |
| 72 | * @param[in] path - Path to attach at. |
| 73 | */ |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 74 | Manager(sdbusplus::bus_t& bus, const char* objPath) : |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 75 | details::ServerObject<details::ManagerIface>(bus, objPath), busLog(bus), |
Patrick Williams | 075c792 | 2024-08-16 15:19:49 -0400 | [diff] [blame] | 76 | entryId(0), fwVersion(readFWVersion()) {}; |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 77 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 78 | /* |
| 79 | * @fn commit() |
| 80 | * @brief sd_bus Commit method implementation callback. |
| 81 | * @details Create an error/event log based on transaction id and |
| 82 | * error message. |
| 83 | * @param[in] transactionId - Unique identifier of the journal entries |
| 84 | * to be committed. |
| 85 | * @param[in] errMsg - The error exception message associated with the |
| 86 | * error log to be committed. |
| 87 | */ |
Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 88 | uint32_t commit(uint64_t transactionId, std::string errMsg) override; |
Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 89 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 90 | /* |
| 91 | * @fn commit() |
| 92 | * @brief sd_bus CommitWithLvl method implementation callback. |
| 93 | * @details Create an error/event log based on transaction id and |
| 94 | * error message. |
| 95 | * @param[in] transactionId - Unique identifier of the journal entries |
| 96 | * to be committed. |
| 97 | * @param[in] errMsg - The error exception message associated with the |
| 98 | * error log to be committed. |
| 99 | * @param[in] errLvl - level of the error |
| 100 | */ |
Lei YU | b50c705 | 2021-01-21 16:02:26 +0800 | [diff] [blame] | 101 | uint32_t commitWithLvl(uint64_t transactionId, std::string errMsg, |
| 102 | uint32_t errLvl) override; |
Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 103 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 104 | /** @brief Erase specified entry d-bus object |
| 105 | * |
| 106 | * @param[in] entryId - unique identifier of the entry |
| 107 | */ |
| 108 | void erase(uint32_t entryId); |
Deepak Kodihalli | 99a8549 | 2017-03-31 06:01:57 -0500 | [diff] [blame] | 109 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 110 | /** @brief Construct error d-bus objects from their persisted |
| 111 | * representations. |
| 112 | */ |
| 113 | void restore(); |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 114 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 115 | /** @brief Erase all error log entries |
| 116 | * |
BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame] | 117 | * @return size_t - count of erased entries |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 118 | */ |
harsh-agarwal1 | d763db3 | 2024-09-03 09:18:50 -0500 | [diff] [blame^] | 119 | size_t eraseAll(); |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 120 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 121 | /** @brief Returns the count of high severity errors |
| 122 | * |
| 123 | * @return int - count of real errors |
| 124 | */ |
| 125 | int getRealErrSize(); |
Nagaraju Goruganti | 477b731 | 2018-06-25 23:28:58 -0500 | [diff] [blame] | 126 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 127 | /** @brief Returns the count of Info errors |
| 128 | * |
| 129 | * @return int - count of info errors |
| 130 | */ |
| 131 | int getInfoErrSize(); |
Nagaraju Goruganti | 477b731 | 2018-06-25 23:28:58 -0500 | [diff] [blame] | 132 | |
Andrew Geissler | 6a0ef6f | 2020-04-06 15:06:31 -0500 | [diff] [blame] | 133 | /** @brief Returns the number of blocking errors |
| 134 | * |
| 135 | * @return int - count of blocking errors |
| 136 | */ |
| 137 | int getBlockingErrSize() |
| 138 | { |
| 139 | return blockingErrors.size(); |
| 140 | } |
| 141 | |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 142 | /** @brief Returns the number of property change callback objects |
| 143 | * |
| 144 | * @return int - count of property callback entries |
| 145 | */ |
| 146 | int getEntryCallbackSize() |
| 147 | { |
| 148 | return propChangedEntryCallback.size(); |
| 149 | } |
| 150 | |
Matt Spinler | 44893cc | 2020-08-26 11:34:17 -0500 | [diff] [blame] | 151 | /** |
| 152 | * @brief Returns the sdbusplus bus object |
| 153 | * |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 154 | * @return sdbusplus::bus_t& |
Matt Spinler | 44893cc | 2020-08-26 11:34:17 -0500 | [diff] [blame] | 155 | */ |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 156 | sdbusplus::bus_t& getBus() |
Matt Spinler | 8ebfd31 | 2019-06-03 12:43:59 -0500 | [diff] [blame] | 157 | { |
| 158 | return busLog; |
| 159 | } |
| 160 | |
Matt Spinler | 44893cc | 2020-08-26 11:34:17 -0500 | [diff] [blame] | 161 | /** |
| 162 | * @brief Returns the ID of the last created entry |
| 163 | * |
| 164 | * @return uint32_t - The ID |
| 165 | */ |
| 166 | uint32_t lastEntryID() const |
| 167 | { |
| 168 | return entryId; |
| 169 | } |
| 170 | |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 171 | /** @brief Creates an event log |
| 172 | * |
| 173 | * This is an alternative to the _commit() API. It doesn't use |
| 174 | * the journal to look up event log metadata like _commit does. |
| 175 | * |
| 176 | * @param[in] errMsg - The error exception message associated with the |
| 177 | * error log to be committed. |
| 178 | * @param[in] severity - level of the error |
| 179 | * @param[in] additionalData - The AdditionalData property for the error |
Paul Fertser | 221b79b | 2024-03-04 15:40:23 +0000 | [diff] [blame] | 180 | * @param[in] ffdc - A vector of tuples that allows one to pass in file |
| 181 | * descriptors for files that contain FFDC (First |
| 182 | * Failure Data Capture). These will be passed to any |
| 183 | * event logging extensions. |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 184 | */ |
BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame] | 185 | void create(const std::string& message, Severity severity, |
Paul Fertser | 221b79b | 2024-03-04 15:40:23 +0000 | [diff] [blame] | 186 | const std::map<std::string, std::string>& additionalData, |
| 187 | const FFDCEntries& ffdc = FFDCEntries{}); |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 188 | |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 189 | /** @brief Common wrapper for creating an Entry object |
| 190 | * |
| 191 | * @return true if quiesce on error setting is enabled, false otherwise |
| 192 | */ |
| 193 | bool isQuiesceOnErrorEnabled(); |
| 194 | |
Andrew Geissler | 3287454 | 2020-07-09 09:17:03 -0500 | [diff] [blame] | 195 | /** @brief Create boot block association and quiesce host if running |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 196 | * |
Andrew Geissler | 3287454 | 2020-07-09 09:17:03 -0500 | [diff] [blame] | 197 | * @param[in] entryId - The ID of the phosphor logging error |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 198 | */ |
Andrew Geissler | 3287454 | 2020-07-09 09:17:03 -0500 | [diff] [blame] | 199 | void quiesceOnError(const uint32_t entryId); |
Andrew Geissler | c0c500e | 2020-03-26 11:08:56 -0500 | [diff] [blame] | 200 | |
Andrew Geissler | e4960ee | 2020-03-30 14:31:52 -0500 | [diff] [blame] | 201 | /** @brief Check if inventory callout present in input entry |
| 202 | * |
| 203 | * @param[in] entry - The error to check for callouts |
| 204 | * |
| 205 | * @return true if inventory item in associations, false otherwise |
| 206 | */ |
| 207 | bool isCalloutPresent(const Entry& entry); |
| 208 | |
Andrew Geissler | ced6e2a | 2020-04-07 16:15:29 -0500 | [diff] [blame] | 209 | /** @brief Check (and remove) entry being erased from blocking errors |
| 210 | * |
| 211 | * @param[in] entryId - The entry that is being erased |
| 212 | */ |
| 213 | void checkAndRemoveBlockingError(uint32_t entryId); |
| 214 | |
Adriana Kobylak | e7d271a | 2020-12-07 14:32:44 -0600 | [diff] [blame] | 215 | /** @brief Persistent map of Entry dbus objects and their ID */ |
| 216 | std::map<uint32_t, std::unique_ptr<Entry>> entries; |
| 217 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 218 | private: |
| 219 | /* |
| 220 | * @fn _commit() |
| 221 | * @brief commit() helper |
| 222 | * @param[in] transactionId - Unique identifier of the journal entries |
| 223 | * to be committed. |
| 224 | * @param[in] errMsg - The error exception message associated with the |
| 225 | * error log to be committed. |
| 226 | * @param[in] errLvl - level of the error |
| 227 | */ |
| 228 | void _commit(uint64_t transactionId, std::string&& errMsg, |
| 229 | Entry::Level errLvl); |
Deepak Kodihalli | 6fd9dc4 | 2018-04-03 02:08:42 -0500 | [diff] [blame] | 230 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 231 | /** @brief Call metadata handler(s), if any. Handlers may create |
| 232 | * associations. |
| 233 | * @param[in] errorName - name of the error |
| 234 | * @param[in] additionalData - list of metadata (in key=value format) |
| 235 | * @param[out] objects - list of error's association objects |
| 236 | */ |
| 237 | void processMetadata(const std::string& errorName, |
| 238 | const std::vector<std::string>& additionalData, |
| 239 | AssociationList& objects) const; |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 240 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 241 | /** @brief Reads the BMC code level |
| 242 | * |
| 243 | * @return std::string - the version string |
| 244 | */ |
| 245 | static std::string readFWVersion(); |
Matt Spinler | 1275bd1 | 2018-05-01 15:13:53 -0500 | [diff] [blame] | 246 | |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 247 | /** @brief Call any create() functions provided by any extensions. |
| 248 | * This is called right after an event log is created to allow |
| 249 | * extensions to create their own log based on this one. |
| 250 | * |
| 251 | * @param[in] entry - the new event log entry |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 252 | * @param[in] ffdc - A vector of FFDC file info |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 253 | */ |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 254 | void doExtensionLogCreate(const Entry& entry, const FFDCEntries& ffdc); |
Matt Spinler | 99c2b40 | 2019-05-23 14:29:16 -0500 | [diff] [blame] | 255 | |
Matt Spinler | b60e755 | 2019-07-24 15:28:08 -0500 | [diff] [blame] | 256 | /** @brief Common wrapper for creating an Entry object |
| 257 | * |
| 258 | * @param[in] errMsg - The error exception message associated with the |
| 259 | * error log to be committed. |
| 260 | * @param[in] errLvl - level of the error |
| 261 | * @param[in] additionalData - The AdditionalData property for the error |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 262 | * @param[in] ffdc - A vector of FFDC file info. Defaults to an empty |
| 263 | * vector. |
Matt Spinler | b60e755 | 2019-07-24 15:28:08 -0500 | [diff] [blame] | 264 | */ |
| 265 | void createEntry(std::string errMsg, Entry::Level errLvl, |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 266 | std::vector<std::string> additionalData, |
| 267 | const FFDCEntries& ffdc = FFDCEntries{}); |
Matt Spinler | b60e755 | 2019-07-24 15:28:08 -0500 | [diff] [blame] | 268 | |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 269 | /** @brief Notified on entry property changes |
| 270 | * |
| 271 | * If an entry is blocking, this callback will be registered to monitor for |
| 272 | * the entry having it's Resolved field set to true. If it is then remove |
| 273 | * the blocking object. |
| 274 | * |
| 275 | * @param[in] msg - sdbusplus dbusmessage |
| 276 | */ |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 277 | void onEntryResolve(sdbusplus::message_t& msg); |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 278 | |
| 279 | /** @brief Remove block objects for any resolved entries */ |
| 280 | void findAndRemoveResolvedBlocks(); |
| 281 | |
Andrew Geissler | f6126a7 | 2020-05-08 10:41:09 -0500 | [diff] [blame] | 282 | /** @brief Quiesce host if it is running |
| 283 | * |
| 284 | * This is called when the user has requested the system be quiesced |
| 285 | * if a log with a callout is created |
| 286 | */ |
| 287 | void checkAndQuiesceHost(); |
| 288 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 289 | /** @brief Persistent sdbusplus DBus bus connection. */ |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 290 | sdbusplus::bus_t& busLog; |
Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 291 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 292 | /** @brief List of error ids for high severity errors */ |
| 293 | std::list<uint32_t> realErrors; |
Nagaraju Goruganti | e4b0b77 | 2017-11-30 02:12:45 -0600 | [diff] [blame] | 294 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 295 | /** @brief List of error ids for Info(and below) severity */ |
| 296 | std::list<uint32_t> infoErrors; |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame] | 297 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 298 | /** @brief Id of last error log entry */ |
| 299 | uint32_t entryId; |
Matt Spinler | 1275bd1 | 2018-05-01 15:13:53 -0500 | [diff] [blame] | 300 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 301 | /** @brief The BMC firmware version */ |
| 302 | const std::string fwVersion; |
Andrew Geissler | 6a0ef6f | 2020-04-06 15:06:31 -0500 | [diff] [blame] | 303 | |
| 304 | /** @brief Array of blocking errors */ |
| 305 | std::vector<std::unique_ptr<Block>> blockingErrors; |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 306 | |
| 307 | /** @brief Map of entry id to call back object on properties changed */ |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 308 | std::map<uint32_t, std::unique_ptr<sdbusplus::bus::match_t>> |
Andrew Geissler | 7f6d4bc | 2020-04-16 14:47:34 -0500 | [diff] [blame] | 309 | propChangedEntryCallback; |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 310 | }; |
| 311 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 312 | } // namespace internal |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 313 | |
| 314 | /** @class Manager |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 315 | * @brief Implementation for deleting all error log entries and |
| 316 | * creating new logs. |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 317 | * @details A concrete implementation for the |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 318 | * xyz.openbmc_project.Collection.DeleteAll and |
| 319 | * xyz.openbmc_project.Logging.Create interfaces. |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 320 | */ |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 321 | class Manager : public details::ServerObject<DeleteAllIface, CreateIface> |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 322 | { |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 323 | public: |
| 324 | Manager() = delete; |
| 325 | Manager(const Manager&) = delete; |
| 326 | Manager& operator=(const Manager&) = delete; |
| 327 | Manager(Manager&&) = delete; |
| 328 | Manager& operator=(Manager&&) = delete; |
| 329 | virtual ~Manager() = default; |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 330 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 331 | /** @brief Constructor to put object onto bus at a dbus path. |
| 332 | * Defer signal registration (pass true for deferSignal to the |
| 333 | * base class) until after the properties are set. |
| 334 | * @param[in] bus - Bus to attach to. |
| 335 | * @param[in] path - Path to attach at. |
| 336 | * @param[in] manager - Reference to internal manager object. |
| 337 | */ |
Patrick Williams | 45e8352 | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 338 | Manager(sdbusplus::bus_t& bus, const std::string& path, |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 339 | internal::Manager& manager) : |
Patrick Williams | 6ef6b25 | 2022-03-30 14:28:27 -0500 | [diff] [blame] | 340 | details::ServerObject<DeleteAllIface, CreateIface>( |
| 341 | bus, path.c_str(), |
| 342 | details::ServerObject<DeleteAllIface, |
| 343 | CreateIface>::action::defer_emit), |
Patrick Williams | 075c792 | 2024-08-16 15:19:49 -0400 | [diff] [blame] | 344 | manager(manager) {}; |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 345 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 346 | /** @brief Delete all d-bus objects. |
| 347 | */ |
Patrick Williams | ec4eaea | 2021-08-28 15:10:15 -0500 | [diff] [blame] | 348 | void deleteAll() override |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 349 | { |
Matt Spinler | f6f5123 | 2022-03-09 10:11:53 -0600 | [diff] [blame] | 350 | log<level::INFO>("Deleting all log entries"); |
BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame] | 351 | auto numbersOfLogs = manager.eraseAll(); |
| 352 | std::map<std::string, std::string> additionalData; |
| 353 | additionalData.emplace("NUM_LOGS", std::to_string(numbersOfLogs)); |
| 354 | manager.create(LogsCleared::errName, Severity::Informational, |
| 355 | additionalData); |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 356 | } |
| 357 | |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 358 | /** @brief D-Bus method call implementation to create an event log. |
| 359 | * |
| 360 | * @param[in] errMsg - The error exception message associated with the |
| 361 | * error log to be committed. |
| 362 | * @param[in] severity - Level of the error |
| 363 | * @param[in] additionalData - The AdditionalData property for the error |
| 364 | */ |
BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame] | 365 | void create(std::string message, Severity severity, |
| 366 | std::map<std::string, std::string> additionalData) override |
Matt Spinler | 3fb83b3 | 2019-07-26 11:22:44 -0500 | [diff] [blame] | 367 | { |
| 368 | manager.create(message, severity, additionalData); |
| 369 | } |
| 370 | |
Matt Spinler | c64b712 | 2020-03-26 10:55:01 -0500 | [diff] [blame] | 371 | /** @brief D-Bus method call implementation to create an event log with FFDC |
| 372 | * |
| 373 | * The same as create(), but takes an extra FFDC argument. |
| 374 | * |
| 375 | * @param[in] errMsg - The error exception message associated with the |
| 376 | * error log to be committed. |
| 377 | * @param[in] severity - Level of the error |
| 378 | * @param[in] additionalData - The AdditionalData property for the error |
| 379 | * @param[in] ffdc - A vector of FFDC file info |
| 380 | */ |
Matt Spinler | fcbaf3e | 2020-03-23 09:22:45 -0500 | [diff] [blame] | 381 | void createWithFFDCFiles( |
BonnieLo-wiwynn | 6f53366 | 2023-04-27 13:41:44 +0800 | [diff] [blame] | 382 | std::string message, Severity severity, |
Matt Spinler | fcbaf3e | 2020-03-23 09:22:45 -0500 | [diff] [blame] | 383 | std::map<std::string, std::string> additionalData, |
| 384 | std::vector<std::tuple<CreateIface::FFDCFormat, uint8_t, uint8_t, |
| 385 | sdbusplus::message::unix_fd>> |
| 386 | ffdc) override |
| 387 | { |
Paul Fertser | 221b79b | 2024-03-04 15:40:23 +0000 | [diff] [blame] | 388 | manager.create(message, severity, additionalData, ffdc); |
Matt Spinler | fcbaf3e | 2020-03-23 09:22:45 -0500 | [diff] [blame] | 389 | } |
| 390 | |
Patrick Venture | f18bf83 | 2018-10-26 18:14:00 -0700 | [diff] [blame] | 391 | private: |
| 392 | /** @brief This is a reference to manager object */ |
| 393 | internal::Manager& manager; |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 394 | }; |
| 395 | |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 396 | } // namespace logging |
| 397 | } // namespace phosphor |