Add event log for log cleared

-Create log on d-bus when user cleared all log entries.

Tested: tested and verified the implementation on greatlakes platform.
-Call method DeleteAll and check the d-bus path for event log.

Change-Id: Ib0e71b014608a25cc17bd803768b53774b8f4539
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
diff --git a/log_manager.hpp b/log_manager.hpp
index 8f5ca43..3fe8fee 100644
--- a/log_manager.hpp
+++ b/log_manager.hpp
@@ -6,6 +6,7 @@
 #include "xyz/openbmc_project/Logging/Create/server.hpp"
 #include "xyz/openbmc_project/Logging/Entry/server.hpp"
 #include "xyz/openbmc_project/Logging/Internal/Manager/server.hpp"
+#include "xyz/openbmc_project/Logging/error.hpp"
 
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/bus.hpp>
@@ -24,6 +25,10 @@
 using DeleteAllIface =
     sdbusplus::server::xyz::openbmc_project::collection::DeleteAll;
 
+using Severity = sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level;
+using LogsCleared =
+    sdbusplus::xyz::openbmc_project::Logging::Error::LogsCleared;
+
 namespace details
 {
 template <typename... T>
@@ -109,9 +114,11 @@
 
     /** @brief  Erase all error log entries
      *
+     *  @return size_t - count of erased entries
      */
-    void eraseAll()
+    size_t eraseAll()
     {
+        size_t entriesSize = entries.size();
         auto iter = entries.begin();
         while (iter != entries.end())
         {
@@ -120,6 +127,8 @@
             erase(e);
         }
         entryId = 0;
+
+        return entriesSize;
     }
 
     /** @brief Returns the count of high severity errors
@@ -182,10 +191,8 @@
      * @param[in] severity - level of the error
      * @param[in] additionalData - The AdditionalData property for the error
      */
-    void create(
-        const std::string& message,
-        sdbusplus::server::xyz::openbmc_project::logging::Entry::Level severity,
-        const std::map<std::string, std::string>& additionalData);
+    void create(const std::string& message, Severity severity,
+                const std::map<std::string, std::string>& additionalData);
 
     /** @brief Creates an event log, and accepts FFDC files
      *
@@ -201,11 +208,10 @@
      * @param[in] additionalData - The AdditionalData property for the error
      * @param[in] ffdc - A vector of FFDC file info
      */
-    void createWithFFDC(
-        const std::string& message,
-        sdbusplus::server::xyz::openbmc_project::logging::Entry::Level severity,
-        const std::map<std::string, std::string>& additionalData,
-        const FFDCEntries& ffdc);
+    void
+        createWithFFDC(const std::string& message, Severity severity,
+                       const std::map<std::string, std::string>& additionalData,
+                       const FFDCEntries& ffdc);
 
     /** @brief Common wrapper for creating an Entry object
      *
@@ -369,7 +375,11 @@
     void deleteAll() override
     {
         log<level::INFO>("Deleting all log entries");
-        manager.eraseAll();
+        auto numbersOfLogs = manager.eraseAll();
+        std::map<std::string, std::string> additionalData;
+        additionalData.emplace("NUM_LOGS", std::to_string(numbersOfLogs));
+        manager.create(LogsCleared::errName, Severity::Informational,
+                       additionalData);
     }
 
     /** @brief D-Bus method call implementation to create an event log.
@@ -379,10 +389,8 @@
      * @param[in] severity - Level of the error
      * @param[in] additionalData - The AdditionalData property for the error
      */
-    void create(
-        std::string message,
-        sdbusplus::server::xyz::openbmc_project::logging::Entry::Level severity,
-        std::map<std::string, std::string> additionalData) override
+    void create(std::string message, Severity severity,
+                std::map<std::string, std::string> additionalData) override
     {
         manager.create(message, severity, additionalData);
     }
@@ -398,8 +406,7 @@
      * @param[in] ffdc - A vector of FFDC file info
      */
     void createWithFFDCFiles(
-        std::string message,
-        sdbusplus::server::xyz::openbmc_project::logging::Entry::Level severity,
+        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>>