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