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