Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Adriana Kobylak | f477fe2 | 2017-01-06 11:56:41 -0600 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
Adriana Kobylak | d722b3a | 2017-02-28 12:10:44 -0600 | [diff] [blame] | 4 | #include <phosphor-logging/log.hpp> |
Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 5 | #include "elog_entry.hpp" |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 6 | #include "xyz/openbmc_project/Logging/Internal/Manager/server.hpp" |
| 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace logging |
| 11 | { |
Adriana Kobylak | d722b3a | 2017-02-28 12:10:44 -0600 | [diff] [blame] | 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 | |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 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 | */ |
Adriana Kobylak | f477fe2 | 2017-01-06 11:56:41 -0600 | [diff] [blame] | 32 | class Manager : public details::ServerObject<details::ManagerIface> |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 33 | { |
| 34 | public: |
| 35 | Manager() = delete; |
| 36 | Manager(const Manager&) = delete; |
| 37 | Manager& operator=(const Manager&) = delete; |
Adriana Kobylak | f477fe2 | 2017-01-06 11:56:41 -0600 | [diff] [blame] | 38 | Manager(Manager&&) = delete; |
| 39 | Manager& operator=(Manager&&) = delete; |
| 40 | virtual ~Manager() = default; |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 41 | |
Adriana Kobylak | f477fe2 | 2017-01-06 11:56:41 -0600 | [diff] [blame] | 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. |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 45 | */ |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 46 | Manager(sdbusplus::bus::bus& bus, const char* objPath) : |
| 47 | details::ServerObject<details::ManagerIface>(bus, objPath), |
| 48 | busLog(bus), |
Marri Devender Rao | 7656fba | 2017-08-06 05:42:52 -0500 | [diff] [blame^] | 49 | entryId(0), |
| 50 | capped(false) {}; |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * @fn commit() |
| 54 | * @brief sd_bus Commit method implementation callback. |
| 55 | * @details Create an error/event log based on transaction id and |
| 56 | * error message. |
| 57 | * @param[in] transactionId - Unique identifier of the journal entries |
| 58 | * to be committed. |
| 59 | * @param[in] errMsg - The error exception message associated with the |
| 60 | * error log to be committed. |
| 61 | */ |
| 62 | void commit(uint64_t transactionId, std::string errMsg) override; |
Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 63 | |
| 64 | |
Deepak Kodihalli | 99a8549 | 2017-03-31 06:01:57 -0500 | [diff] [blame] | 65 | /** @brief Erase specified entry d-bus object |
| 66 | * |
| 67 | * @param[in] entryId - unique identifier of the entry |
| 68 | */ |
| 69 | void erase(uint32_t entryId); |
| 70 | |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 71 | /** @brief Construct error d-bus objects from their persisted |
| 72 | * representations. |
| 73 | */ |
| 74 | void restore(); |
| 75 | |
Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 76 | private: |
Deepak Kodihalli | a87c157 | 2017-02-28 07:40:34 -0600 | [diff] [blame] | 77 | /** @brief Call metadata handler(s), if any. Handlers may create |
| 78 | * associations. |
| 79 | * @param[in] errorName - name of the error |
| 80 | * @param[in] additionalData - list of metadata (in key=value format) |
| 81 | * @param[out] objects - list of error's association objects |
| 82 | */ |
| 83 | void processMetadata(const std::string& errorName, |
| 84 | const std::vector<std::string>& additionalData, |
| 85 | AssociationList& objects) const; |
| 86 | |
Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 87 | /** @brief Persistent sdbusplus DBus bus connection. */ |
| 88 | sdbusplus::bus::bus& busLog; |
| 89 | |
| 90 | /** @brief Persistent map of Entry dbus objects and their ID */ |
| 91 | std::map<uint32_t, std::unique_ptr<Entry>> entries; |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 92 | |
| 93 | /** @brief Id of last error log entry */ |
| 94 | uint32_t entryId; |
Marri Devender Rao | 7656fba | 2017-08-06 05:42:52 -0500 | [diff] [blame^] | 95 | |
| 96 | /** |
| 97 | * @brief Flag to log error for the first time when error cap is |
| 98 | * reached. |
| 99 | * @details Flag used to log error message for the first time when the |
| 100 | * error cap value is reached. It is reset when user delete's error |
| 101 | * entries and total entries existing is less than the error cap |
| 102 | * value. |
| 103 | */ |
| 104 | bool capped; |
Adriana Kobylak | 8f7941e | 2016-11-14 14:46:23 -0600 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | } // namespace logging |
| 108 | } // namespace phosphor |