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/gen/xyz/openbmc_project/Logging/meson.build b/gen/xyz/openbmc_project/Logging/meson.build
index 6421d35..c27f679 100644
--- a/gen/xyz/openbmc_project/Logging/meson.build
+++ b/gen/xyz/openbmc_project/Logging/meson.build
@@ -1,2 +1,16 @@
# Generated file; do not modify.
+generated_sources += custom_target(
+ 'xyz/openbmc_project/Logging__cpp'.underscorify(),
+ input: [ '../../../../yaml/xyz/openbmc_project/Logging.errors.yaml', ],
+ output: [ 'error.cpp', 'error.hpp', ],
+ depend_files: sdbusplusplus_depfiles,
+ command: [
+ sdbuspp_gen_meson_prog, '--command', 'cpp',
+ '--output', meson.current_build_dir(),
+ '--tool', sdbusplusplus_prog,
+ '--directory', meson.current_source_dir() / '../../../../yaml',
+ 'xyz/openbmc_project/Logging',
+ ],
+)
+
subdir('Internal')
diff --git a/gen/xyz/openbmc_project/meson.build b/gen/xyz/openbmc_project/meson.build
index 1b45c9d..1e56539 100644
--- a/gen/xyz/openbmc_project/meson.build
+++ b/gen/xyz/openbmc_project/meson.build
@@ -1,2 +1,16 @@
# Generated file; do not modify.
subdir('Logging')
+generated_others += custom_target(
+ 'xyz/openbmc_project/Logging__markdown'.underscorify(),
+ input: [ '../../../yaml/xyz/openbmc_project/Logging.errors.yaml', ],
+ output: [ 'Logging.md' ],
+ depend_files: sdbusplusplus_depfiles,
+ command: [
+ sdbuspp_gen_meson_prog, '--command', 'markdown',
+ '--output', meson.current_build_dir(),
+ '--tool', sdbusplusplus_prog,
+ '--directory', meson.current_source_dir() / '../../../yaml',
+ 'xyz/openbmc_project/Logging',
+ ],
+)
+
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>>
diff --git a/yaml/xyz/openbmc_project/Logging.errors.yaml b/yaml/xyz/openbmc_project/Logging.errors.yaml
new file mode 100644
index 0000000..e90bc7c
--- /dev/null
+++ b/yaml/xyz/openbmc_project/Logging.errors.yaml
@@ -0,0 +1,3 @@
+# xyz.openbmc_project.Logging.Error
+- name: LogsCleared
+ description: Indicate the user cleared all the logs
diff --git a/yaml/xyz/openbmc_project/Logging.metadata.yaml b/yaml/xyz/openbmc_project/Logging.metadata.yaml
new file mode 100644
index 0000000..99d647a
--- /dev/null
+++ b/yaml/xyz/openbmc_project/Logging.metadata.yaml
@@ -0,0 +1,5 @@
+- name: LogsCleared
+ level: INFO
+ meta:
+ - str: "NUM_LOGS=%u"
+ type: size_t