xref: /openbmc/phosphor-logging/log_manager.hpp (revision ea21d995389412b4cea411f647176641b5cf0a9a)
18f7941edSAdriana Kobylak #pragma once
28f7941edSAdriana Kobylak 
36a0ef6f5SAndrew Geissler #include "elog_block.hpp"
4df995fafSAdriana Kobylak #include "elog_entry.hpp"
5f18bf836SPatrick Venture #include "xyz/openbmc_project/Logging/Internal/Manager/server.hpp"
6f18bf836SPatrick Venture 
7f18bf836SPatrick Venture #include <phosphor-logging/log.hpp>
8f18bf836SPatrick Venture #include <sdbusplus/bus.hpp>
99ca4d137SPatrick Williams #include <xyz/openbmc_project/Collection/DeleteAll/server.hpp>
109ca4d137SPatrick Williams #include <xyz/openbmc_project/Logging/Create/server.hpp>
119ca4d137SPatrick Williams #include <xyz/openbmc_project/Logging/Entry/server.hpp>
129ca4d137SPatrick Williams #include <xyz/openbmc_project/Logging/event.hpp>
138f7941edSAdriana Kobylak 
142544b419SPatrick Williams #include <list>
152544b419SPatrick Williams 
168f7941edSAdriana Kobylak namespace phosphor
178f7941edSAdriana Kobylak {
188f7941edSAdriana Kobylak namespace logging
198f7941edSAdriana Kobylak {
20d722b3aaSAdriana Kobylak 
21d722b3aaSAdriana Kobylak extern const std::map<std::string, std::vector<std::string>> g_errMetaMap;
22d722b3aaSAdriana Kobylak extern const std::map<std::string, level> g_errLevelMap;
23d722b3aaSAdriana Kobylak 
246ddbf69eSWilly Tu using CreateIface = sdbusplus::server::xyz::openbmc_project::logging::Create;
253fb83b37SMatt Spinler using DeleteAllIface =
266ddbf69eSWilly Tu     sdbusplus::server::xyz::openbmc_project::collection::DeleteAll;
2705aae8bcSNagaraju Goruganti 
286f533669SBonnieLo-wiwynn using Severity = sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level;
299ca4d137SPatrick Williams using LoggingCleared = sdbusplus::event::xyz::openbmc_project::Logging::Cleared;
306f533669SBonnieLo-wiwynn 
318f7941edSAdriana Kobylak namespace details
328f7941edSAdriana Kobylak {
333fb83b37SMatt Spinler template <typename... T>
3445e83521SPatrick Williams using ServerObject = typename sdbusplus::server::object_t<T...>;
358f7941edSAdriana Kobylak 
368f7941edSAdriana Kobylak using ManagerIface =
376ddbf69eSWilly Tu     sdbusplus::server::xyz::openbmc_project::logging::internal::Manager;
388f7941edSAdriana Kobylak 
398f7941edSAdriana Kobylak } // namespace details
408f7941edSAdriana Kobylak 
41c64b7122SMatt Spinler constexpr size_t ffdcFormatPos = 0;
42c64b7122SMatt Spinler constexpr size_t ffdcSubtypePos = 1;
43c64b7122SMatt Spinler constexpr size_t ffdcVersionPos = 2;
44c64b7122SMatt Spinler constexpr size_t ffdcFDPos = 3;
45c64b7122SMatt Spinler 
46c64b7122SMatt Spinler using FFDCEntry = std::tuple<CreateIface::FFDCFormat, uint8_t, uint8_t,
47c64b7122SMatt Spinler                              sdbusplus::message::unix_fd>;
48c64b7122SMatt Spinler 
49c64b7122SMatt Spinler using FFDCEntries = std::vector<FFDCEntry>;
50c64b7122SMatt Spinler 
5105aae8bcSNagaraju Goruganti namespace internal
5205aae8bcSNagaraju Goruganti {
5305aae8bcSNagaraju Goruganti 
548f7941edSAdriana Kobylak /** @class Manager
558f7941edSAdriana Kobylak  *  @brief OpenBMC logging manager implementation.
568f7941edSAdriana Kobylak  *  @details A concrete implementation for the
578f7941edSAdriana Kobylak  *  xyz.openbmc_project.Logging.Internal.Manager DBus API.
588f7941edSAdriana Kobylak  */
59f477fe29SAdriana Kobylak class Manager : public details::ServerObject<details::ManagerIface>
608f7941edSAdriana Kobylak {
618f7941edSAdriana Kobylak   public:
628f7941edSAdriana Kobylak     Manager() = delete;
638f7941edSAdriana Kobylak     Manager(const Manager&) = delete;
648f7941edSAdriana Kobylak     Manager& operator=(const Manager&) = delete;
65f477fe29SAdriana Kobylak     Manager(Manager&&) = delete;
66f477fe29SAdriana Kobylak     Manager& operator=(Manager&&) = delete;
67f477fe29SAdriana Kobylak     virtual ~Manager() = default;
688f7941edSAdriana Kobylak 
69f477fe29SAdriana Kobylak     /** @brief Constructor to put object onto bus at a dbus path.
70f477fe29SAdriana Kobylak      *  @param[in] bus - Bus to attach to.
71f477fe29SAdriana Kobylak      *  @param[in] path - Path to attach at.
728f7941edSAdriana Kobylak      */
Manager(sdbusplus::bus_t & bus,const char * objPath)7345e83521SPatrick Williams     Manager(sdbusplus::bus_t& bus, const char* objPath) :
74f18bf836SPatrick Venture         details::ServerObject<details::ManagerIface>(bus, objPath), busLog(bus),
75f18bf836SPatrick Venture         entryId(0), fwVersion(readFWVersion()) {};
768f7941edSAdriana Kobylak 
778f7941edSAdriana Kobylak     /*
788f7941edSAdriana Kobylak      * @fn commit()
798f7941edSAdriana Kobylak      * @brief sd_bus Commit method implementation callback.
808f7941edSAdriana Kobylak      * @details Create an error/event log based on transaction id and
818f7941edSAdriana Kobylak      *          error message.
828f7941edSAdriana Kobylak      * @param[in] transactionId - Unique identifier of the journal entries
838f7941edSAdriana Kobylak      *                            to be committed.
848f7941edSAdriana Kobylak      * @param[in] errMsg - The error exception message associated with the
858f7941edSAdriana Kobylak      *                     error log to be committed.
868f7941edSAdriana Kobylak      */
87b50c705cSLei YU     uint32_t commit(uint64_t transactionId, std::string errMsg) override;
88df995fafSAdriana Kobylak 
896fd9dc48SDeepak Kodihalli     /*
906fd9dc48SDeepak Kodihalli      * @fn commit()
916fd9dc48SDeepak Kodihalli      * @brief sd_bus CommitWithLvl method implementation callback.
926fd9dc48SDeepak Kodihalli      * @details Create an error/event log based on transaction id and
936fd9dc48SDeepak Kodihalli      *          error message.
946fd9dc48SDeepak Kodihalli      * @param[in] transactionId - Unique identifier of the journal entries
956fd9dc48SDeepak Kodihalli      *                            to be committed.
966fd9dc48SDeepak Kodihalli      * @param[in] errMsg - The error exception message associated with the
976fd9dc48SDeepak Kodihalli      *                     error log to be committed.
986fd9dc48SDeepak Kodihalli      * @param[in] errLvl - level of the error
996fd9dc48SDeepak Kodihalli      */
100b50c705cSLei YU     uint32_t commitWithLvl(uint64_t transactionId, std::string errMsg,
1016fd9dc48SDeepak Kodihalli                            uint32_t errLvl) override;
102df995fafSAdriana Kobylak 
10399a8549eSDeepak Kodihalli     /** @brief Erase specified entry d-bus object
10499a8549eSDeepak Kodihalli      *
10599a8549eSDeepak Kodihalli      * @param[in] entryId - unique identifier of the entry
10699a8549eSDeepak Kodihalli      */
10799a8549eSDeepak Kodihalli     void erase(uint32_t entryId);
10899a8549eSDeepak Kodihalli 
10972654f10SDeepak Kodihalli     /** @brief Construct error d-bus objects from their persisted
11072654f10SDeepak Kodihalli      *         representations.
11172654f10SDeepak Kodihalli      */
11272654f10SDeepak Kodihalli     void restore();
11372654f10SDeepak Kodihalli 
11405aae8bcSNagaraju Goruganti     /** @brief  Erase all error log entries
11505aae8bcSNagaraju Goruganti      *
1166f533669SBonnieLo-wiwynn      *  @return size_t - count of erased entries
11705aae8bcSNagaraju Goruganti      */
118d763db35Sharsh-agarwal1     size_t eraseAll();
11905aae8bcSNagaraju Goruganti 
120477b731aSNagaraju Goruganti     /** @brief Returns the count of high severity errors
121477b731aSNagaraju Goruganti      *
122477b731aSNagaraju Goruganti      *  @return int - count of real errors
123477b731aSNagaraju Goruganti      */
124477b731aSNagaraju Goruganti     int getRealErrSize();
125477b731aSNagaraju Goruganti 
126477b731aSNagaraju Goruganti     /** @brief Returns the count of Info errors
127477b731aSNagaraju Goruganti      *
128477b731aSNagaraju Goruganti      *  @return int - count of info errors
129477b731aSNagaraju Goruganti      */
130477b731aSNagaraju Goruganti     int getInfoErrSize();
131477b731aSNagaraju Goruganti 
1326a0ef6f5SAndrew Geissler     /** @brief Returns the number of blocking errors
1336a0ef6f5SAndrew Geissler      *
1346a0ef6f5SAndrew Geissler      *  @return int - count of blocking errors
1356a0ef6f5SAndrew Geissler      */
getBlockingErrSize()1366a0ef6f5SAndrew Geissler     int getBlockingErrSize()
1376a0ef6f5SAndrew Geissler     {
1386a0ef6f5SAndrew Geissler         return blockingErrors.size();
1396a0ef6f5SAndrew Geissler     }
1406a0ef6f5SAndrew Geissler 
1417f6d4bcfSAndrew Geissler     /** @brief Returns the number of property change callback objects
1427f6d4bcfSAndrew Geissler      *
1437f6d4bcfSAndrew Geissler      *  @return int - count of property callback entries
1447f6d4bcfSAndrew Geissler      */
getEntryCallbackSize()1457f6d4bcfSAndrew Geissler     int getEntryCallbackSize()
1467f6d4bcfSAndrew Geissler     {
1477f6d4bcfSAndrew Geissler         return propChangedEntryCallback.size();
1487f6d4bcfSAndrew Geissler     }
1497f6d4bcfSAndrew Geissler 
15044893cc9SMatt Spinler     /**
15144893cc9SMatt Spinler      * @brief Returns the sdbusplus bus object
15244893cc9SMatt Spinler      *
15345e83521SPatrick Williams      * @return sdbusplus::bus_t&
15444893cc9SMatt Spinler      */
getBus()15545e83521SPatrick Williams     sdbusplus::bus_t& getBus()
1568ebfd312SMatt Spinler     {
1578ebfd312SMatt Spinler         return busLog;
1588ebfd312SMatt Spinler     }
1598ebfd312SMatt Spinler 
16044893cc9SMatt Spinler     /**
16144893cc9SMatt Spinler      * @brief Returns the ID of the last created entry
16244893cc9SMatt Spinler      *
16344893cc9SMatt Spinler      * @return uint32_t - The ID
16444893cc9SMatt Spinler      */
lastEntryID() const16544893cc9SMatt Spinler     uint32_t lastEntryID() const
16644893cc9SMatt Spinler     {
16744893cc9SMatt Spinler         return entryId;
16844893cc9SMatt Spinler     }
16944893cc9SMatt Spinler 
1703fb83b37SMatt Spinler     /** @brief Creates an event log
1713fb83b37SMatt Spinler      *
1723fb83b37SMatt Spinler      *  This is an alternative to the _commit() API.  It doesn't use
1733fb83b37SMatt Spinler      *  the journal to look up event log metadata like _commit does.
1743fb83b37SMatt Spinler      *
1753fb83b37SMatt Spinler      * @param[in] errMsg - The error exception message associated with the
1763fb83b37SMatt Spinler      *                     error log to be committed.
1773fb83b37SMatt Spinler      * @param[in] severity - level of the error
1783fb83b37SMatt Spinler      * @param[in] additionalData - The AdditionalData property for the error
179221b79b3SPaul Fertser      * @param[in] ffdc - A vector of tuples that allows one to pass in file
180221b79b3SPaul Fertser      *                   descriptors for files that contain FFDC (First
181221b79b3SPaul Fertser      *                   Failure Data Capture). These will be passed to any
182221b79b3SPaul Fertser      *                   event logging extensions.
1833fb83b37SMatt Spinler      */
184597f24afSPatrick Williams     auto create(const std::string& message, Severity severity,
185c64b7122SMatt Spinler                 const std::map<std::string, std::string>& additionalData,
186597f24afSPatrick Williams                 const FFDCEntries& ffdc = FFDCEntries{})
187597f24afSPatrick Williams         -> sdbusplus::message::object_path;
188c64b7122SMatt Spinler 
1899ca4d137SPatrick Williams     /** @brief Create an internal event log from the sdbusplus generated event
1909ca4d137SPatrick Williams      *
1919ca4d137SPatrick Williams      *  @param[in] event - The event to create.
1929ca4d137SPatrick Williams      */
1939ca4d137SPatrick Williams     auto createFromEvent(sdbusplus::exception::generated_event_base&& event)
1949ca4d137SPatrick Williams         -> sdbusplus::message::object_path;
1959ca4d137SPatrick Williams 
196c0c500efSAndrew Geissler     /** @brief Common wrapper for creating an Entry object
197c0c500efSAndrew Geissler      *
198c0c500efSAndrew Geissler      * @return true if quiesce on error setting is enabled, false otherwise
199c0c500efSAndrew Geissler      */
200c0c500efSAndrew Geissler     bool isQuiesceOnErrorEnabled();
201c0c500efSAndrew Geissler 
20232874543SAndrew Geissler     /** @brief Create boot block association and quiesce host if running
203c0c500efSAndrew Geissler      *
20432874543SAndrew Geissler      * @param[in] entryId - The ID of the phosphor logging error
205c0c500efSAndrew Geissler      */
20632874543SAndrew Geissler     void quiesceOnError(const uint32_t entryId);
207c0c500efSAndrew Geissler 
208e4960ee7SAndrew Geissler     /** @brief Check if inventory callout present in input entry
209e4960ee7SAndrew Geissler      *
210e4960ee7SAndrew Geissler      * @param[in] entry - The error to check for callouts
211e4960ee7SAndrew Geissler      *
212e4960ee7SAndrew Geissler      * @return true if inventory item in associations, false otherwise
213e4960ee7SAndrew Geissler      */
214e4960ee7SAndrew Geissler     bool isCalloutPresent(const Entry& entry);
215e4960ee7SAndrew Geissler 
216ced6e2a0SAndrew Geissler     /** @brief Check (and remove) entry being erased from blocking errors
217ced6e2a0SAndrew Geissler      *
218ced6e2a0SAndrew Geissler      * @param[in] entryId - The entry that is being erased
219ced6e2a0SAndrew Geissler      */
220ced6e2a0SAndrew Geissler     void checkAndRemoveBlockingError(uint32_t entryId);
221ced6e2a0SAndrew Geissler 
222e7d271aeSAdriana Kobylak     /** @brief Persistent map of Entry dbus objects and their ID */
223e7d271aeSAdriana Kobylak     std::map<uint32_t, std::unique_ptr<Entry>> entries;
224e7d271aeSAdriana Kobylak 
225df995fafSAdriana Kobylak   private:
2266fd9dc48SDeepak Kodihalli     /*
2276fd9dc48SDeepak Kodihalli      * @fn _commit()
2286fd9dc48SDeepak Kodihalli      * @brief commit() helper
2296fd9dc48SDeepak Kodihalli      * @param[in] transactionId - Unique identifier of the journal entries
2306fd9dc48SDeepak Kodihalli      *                            to be committed.
2316fd9dc48SDeepak Kodihalli      * @param[in] errMsg - The error exception message associated with the
2326fd9dc48SDeepak Kodihalli      *                     error log to be committed.
2336fd9dc48SDeepak Kodihalli      * @param[in] errLvl - level of the error
2346fd9dc48SDeepak Kodihalli      */
2356fd9dc48SDeepak Kodihalli     void _commit(uint64_t transactionId, std::string&& errMsg,
2366fd9dc48SDeepak Kodihalli                  Entry::Level errLvl);
2376fd9dc48SDeepak Kodihalli 
238a87c157cSDeepak Kodihalli     /** @brief Call metadata handler(s), if any. Handlers may create
239a87c157cSDeepak Kodihalli      *         associations.
240a87c157cSDeepak Kodihalli      *  @param[in] errorName - name of the error
241a87c157cSDeepak Kodihalli      *  @param[in] additionalData - list of metadata (in key=value format)
242a87c157cSDeepak Kodihalli      *  @param[out] objects - list of error's association objects
243a87c157cSDeepak Kodihalli      */
244a87c157cSDeepak Kodihalli     void processMetadata(const std::string& errorName,
245a87c157cSDeepak Kodihalli                          const std::vector<std::string>& additionalData,
246a87c157cSDeepak Kodihalli                          AssociationList& objects) const;
247a87c157cSDeepak Kodihalli 
2481275bd13SMatt Spinler     /** @brief Reads the BMC code level
2491275bd13SMatt Spinler      *
2501275bd13SMatt Spinler      *  @return std::string - the version string
2511275bd13SMatt Spinler      */
2521275bd13SMatt Spinler     static std::string readFWVersion();
2531275bd13SMatt Spinler 
25499c2b405SMatt Spinler     /** @brief Call any create() functions provided by any extensions.
25599c2b405SMatt Spinler      *  This is called right after an event log is created to allow
25699c2b405SMatt Spinler      *  extensions to create their own log based on this one.
25799c2b405SMatt Spinler      *
25899c2b405SMatt Spinler      *  @param[in] entry - the new event log entry
259c64b7122SMatt Spinler      *  @param[in] ffdc - A vector of FFDC file info
26099c2b405SMatt Spinler      */
261c64b7122SMatt Spinler     void doExtensionLogCreate(const Entry& entry, const FFDCEntries& ffdc);
26299c2b405SMatt Spinler 
263b60e7559SMatt Spinler     /** @brief Common wrapper for creating an Entry object
264b60e7559SMatt Spinler      *
265b60e7559SMatt Spinler      * @param[in] errMsg - The error exception message associated with the
266b60e7559SMatt Spinler      *                     error log to be committed.
267b60e7559SMatt Spinler      * @param[in] errLvl - level of the error
268b60e7559SMatt Spinler      * @param[in] additionalData - The AdditionalData property for the error
269c64b7122SMatt Spinler      * @param[in] ffdc - A vector of FFDC file info. Defaults to an empty
270c64b7122SMatt Spinler      * vector.
271b60e7559SMatt Spinler      */
272597f24afSPatrick Williams     auto createEntry(std::string errMsg, Entry::Level errLvl,
273*ea21d995SPatrick Williams                      std::map<std::string, std::string> additionalData,
274597f24afSPatrick Williams                      const FFDCEntries& ffdc = FFDCEntries{})
275597f24afSPatrick Williams         -> sdbusplus::message::object_path;
276b60e7559SMatt Spinler 
2777f6d4bcfSAndrew Geissler     /** @brief Notified on entry property changes
2787f6d4bcfSAndrew Geissler      *
2797f6d4bcfSAndrew Geissler      * If an entry is blocking, this callback will be registered to monitor for
2807f6d4bcfSAndrew Geissler      * the entry having it's Resolved field set to true. If it is then remove
2817f6d4bcfSAndrew Geissler      * the blocking object.
2827f6d4bcfSAndrew Geissler      *
2837f6d4bcfSAndrew Geissler      * @param[in] msg - sdbusplus dbusmessage
2847f6d4bcfSAndrew Geissler      */
28545e83521SPatrick Williams     void onEntryResolve(sdbusplus::message_t& msg);
2867f6d4bcfSAndrew Geissler 
2877f6d4bcfSAndrew Geissler     /** @brief Remove block objects for any resolved entries  */
2887f6d4bcfSAndrew Geissler     void findAndRemoveResolvedBlocks();
2897f6d4bcfSAndrew Geissler 
290f6126a78SAndrew Geissler     /** @brief Quiesce host if it is running
291f6126a78SAndrew Geissler      *
292f6126a78SAndrew Geissler      * This is called when the user has requested the system be quiesced
293f6126a78SAndrew Geissler      * if a log with a callout is created
294f6126a78SAndrew Geissler      */
295f6126a78SAndrew Geissler     void checkAndQuiesceHost();
296f6126a78SAndrew Geissler 
297df995fafSAdriana Kobylak     /** @brief Persistent sdbusplus DBus bus connection. */
29845e83521SPatrick Williams     sdbusplus::bus_t& busLog;
299df995fafSAdriana Kobylak 
300e4b0b771SNagaraju Goruganti     /** @brief List of error ids for high severity errors */
301e4b0b771SNagaraju Goruganti     std::list<uint32_t> realErrors;
302e4b0b771SNagaraju Goruganti 
303f8a5a797SNagaraju Goruganti     /** @brief List of error ids for Info(and below) severity */
304f8a5a797SNagaraju Goruganti     std::list<uint32_t> infoErrors;
305f8a5a797SNagaraju Goruganti 
3064ea7f312SAdriana Kobylak     /** @brief Id of last error log entry */
3074ea7f312SAdriana Kobylak     uint32_t entryId;
3081275bd13SMatt Spinler 
3091275bd13SMatt Spinler     /** @brief The BMC firmware version */
3101275bd13SMatt Spinler     const std::string fwVersion;
3116a0ef6f5SAndrew Geissler 
3126a0ef6f5SAndrew Geissler     /** @brief Array of blocking errors */
3136a0ef6f5SAndrew Geissler     std::vector<std::unique_ptr<Block>> blockingErrors;
3147f6d4bcfSAndrew Geissler 
3157f6d4bcfSAndrew Geissler     /** @brief Map of entry id to call back object on properties changed */
31645e83521SPatrick Williams     std::map<uint32_t, std::unique_ptr<sdbusplus::bus::match_t>>
3177f6d4bcfSAndrew Geissler         propChangedEntryCallback;
3188f7941edSAdriana Kobylak };
3198f7941edSAdriana Kobylak 
32005aae8bcSNagaraju Goruganti } // namespace internal
32105aae8bcSNagaraju Goruganti 
32205aae8bcSNagaraju Goruganti /** @class Manager
3233fb83b37SMatt Spinler  *  @brief Implementation for deleting all error log entries and
3243fb83b37SMatt Spinler  *         creating new logs.
32505aae8bcSNagaraju Goruganti  *  @details A concrete implementation for the
3263fb83b37SMatt Spinler  *           xyz.openbmc_project.Collection.DeleteAll and
3273fb83b37SMatt Spinler  *           xyz.openbmc_project.Logging.Create interfaces.
32805aae8bcSNagaraju Goruganti  */
3293fb83b37SMatt Spinler class Manager : public details::ServerObject<DeleteAllIface, CreateIface>
33005aae8bcSNagaraju Goruganti {
33105aae8bcSNagaraju Goruganti   public:
33205aae8bcSNagaraju Goruganti     Manager() = delete;
33305aae8bcSNagaraju Goruganti     Manager(const Manager&) = delete;
33405aae8bcSNagaraju Goruganti     Manager& operator=(const Manager&) = delete;
33505aae8bcSNagaraju Goruganti     Manager(Manager&&) = delete;
33605aae8bcSNagaraju Goruganti     Manager& operator=(Manager&&) = delete;
33705aae8bcSNagaraju Goruganti     virtual ~Manager() = default;
33805aae8bcSNagaraju Goruganti 
33905aae8bcSNagaraju Goruganti     /** @brief Constructor to put object onto bus at a dbus path.
34005aae8bcSNagaraju Goruganti      *         Defer signal registration (pass true for deferSignal to the
34105aae8bcSNagaraju Goruganti      *         base class) until after the properties are set.
34205aae8bcSNagaraju Goruganti      *  @param[in] bus - Bus to attach to.
34305aae8bcSNagaraju Goruganti      *  @param[in] path - Path to attach at.
34405aae8bcSNagaraju Goruganti      *  @param[in] manager - Reference to internal manager object.
34505aae8bcSNagaraju Goruganti      */
Manager(sdbusplus::bus_t & bus,const std::string & path,internal::Manager & manager)34645e83521SPatrick Williams     Manager(sdbusplus::bus_t& bus, const std::string& path,
34705aae8bcSNagaraju Goruganti             internal::Manager& manager) :
3486ef6b25eSPatrick Williams         details::ServerObject<DeleteAllIface, CreateIface>(
3496ef6b25eSPatrick Williams             bus, path.c_str(),
3506ef6b25eSPatrick Williams             details::ServerObject<DeleteAllIface,
3516ef6b25eSPatrick Williams                                   CreateIface>::action::defer_emit),
35205aae8bcSNagaraju Goruganti         manager(manager) {};
35305aae8bcSNagaraju Goruganti 
35405aae8bcSNagaraju Goruganti     /** @brief Delete all d-bus objects.
35505aae8bcSNagaraju Goruganti      */
deleteAll()356ec4eaea9SPatrick Williams     void deleteAll() override
35705aae8bcSNagaraju Goruganti     {
358f6f51230SMatt Spinler         log<level::INFO>("Deleting all log entries");
3596f533669SBonnieLo-wiwynn         auto numbersOfLogs = manager.eraseAll();
3609ca4d137SPatrick Williams         manager.createFromEvent(
3619ca4d137SPatrick Williams             LoggingCleared("NUMBER_OF_LOGS", numbersOfLogs));
36205aae8bcSNagaraju Goruganti     }
363f18bf836SPatrick Venture 
3643fb83b37SMatt Spinler     /** @brief D-Bus method call implementation to create an event log.
3653fb83b37SMatt Spinler      *
3663fb83b37SMatt Spinler      * @param[in] errMsg - The error exception message associated with the
3673fb83b37SMatt Spinler      *                     error log to be committed.
3683fb83b37SMatt Spinler      * @param[in] severity - Level of the error
3693fb83b37SMatt Spinler      * @param[in] additionalData - The AdditionalData property for the error
3703fb83b37SMatt Spinler      */
create(std::string message,Severity severity,std::map<std::string,std::string> additionalData)371597f24afSPatrick Williams     auto create(std::string message, Severity severity,
372597f24afSPatrick Williams                 std::map<std::string, std::string> additionalData)
373597f24afSPatrick Williams         -> sdbusplus::message::object_path override
3743fb83b37SMatt Spinler     {
375597f24afSPatrick Williams         return manager.create(message, severity, additionalData);
3763fb83b37SMatt Spinler     }
3773fb83b37SMatt Spinler 
378c64b7122SMatt Spinler     /** @brief D-Bus method call implementation to create an event log with FFDC
379c64b7122SMatt Spinler      *
380c64b7122SMatt Spinler      * The same as create(), but takes an extra FFDC argument.
381c64b7122SMatt Spinler      *
382c64b7122SMatt Spinler      * @param[in] errMsg - The error exception message associated with the
383c64b7122SMatt Spinler      *                     error log to be committed.
384c64b7122SMatt Spinler      * @param[in] severity - Level of the error
385c64b7122SMatt Spinler      * @param[in] additionalData - The AdditionalData property for the error
386c64b7122SMatt Spinler      * @param[in] ffdc - A vector of FFDC file info
387c64b7122SMatt Spinler      */
createWithFFDCFiles(std::string message,Severity severity,std::map<std::string,std::string> additionalData,std::vector<std::tuple<CreateIface::FFDCFormat,uint8_t,uint8_t,sdbusplus::message::unix_fd>> ffdc)388fcbaf3e8SMatt Spinler     void createWithFFDCFiles(
3896f533669SBonnieLo-wiwynn         std::string message, Severity severity,
390fcbaf3e8SMatt Spinler         std::map<std::string, std::string> additionalData,
391fcbaf3e8SMatt Spinler         std::vector<std::tuple<CreateIface::FFDCFormat, uint8_t, uint8_t,
392fcbaf3e8SMatt Spinler                                sdbusplus::message::unix_fd>>
393fcbaf3e8SMatt Spinler             ffdc) override
394fcbaf3e8SMatt Spinler     {
395221b79b3SPaul Fertser         manager.create(message, severity, additionalData, ffdc);
396fcbaf3e8SMatt Spinler     }
397fcbaf3e8SMatt Spinler 
39805aae8bcSNagaraju Goruganti   private:
39905aae8bcSNagaraju Goruganti     /** @brief This is a reference to manager object */
40005aae8bcSNagaraju Goruganti     internal::Manager& manager;
40105aae8bcSNagaraju Goruganti };
40205aae8bcSNagaraju Goruganti 
4038f7941edSAdriana Kobylak } // namespace logging
4048f7941edSAdriana Kobylak } // namespace phosphor
405