summaryrefslogtreecommitdiffstats
path: root/log_manager.hpp
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-07-26 11:22:44 -0500
committerMatt Spinler <spinler@us.ibm.com>2019-08-05 12:49:54 -0500
commit3fb83b3787c8440e48d37eb4c488fa253d63a807 (patch)
tree85456b6d57833f840484d3817711f325e86e397c /log_manager.hpp
parentb60e7559cf72fd42cc860101167f02335641ba90 (diff)
downloadphosphor-logging-3fb83b3787c8440e48d37eb4c488fa253d63a807.tar.gz
phosphor-logging-3fb83b3787c8440e48d37eb4c488fa253d63a807.zip
Implement Logging.Create interface
This adds the xyz.openbmc_project.Logging.Create interface on the /xyz/openbmc_project/logging path. The interface provides a single method, Create, that allows one to create an event log. This is an alternative to using the report/commit functions provided by the phosphor-logging/elog.hpp header file. Unlike those report/commit interfaces, this does not require that the entries in the AdditionalData event log property be defined ahead of time, as the whole AdditionalData contents are just passed in instead of read out of the journal. This means that the error does not need to have been defined in the error and metadata YAML files for an event log to be successfully created. The discussion on if that is still desired anyway is outside the scope of this commit. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: Icf3f740ab86605deeaeb955ff51aa2ef292f5af4
Diffstat (limited to 'log_manager.hpp')
-rw-r--r--log_manager.hpp53
1 files changed, 44 insertions, 9 deletions
diff --git a/log_manager.hpp b/log_manager.hpp
index 15dd3af..c5ae081 100644
--- a/log_manager.hpp
+++ b/log_manager.hpp
@@ -2,6 +2,8 @@
#include "elog_entry.hpp"
#include "xyz/openbmc_project/Collection/DeleteAll/server.hpp"
+#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 <list>
@@ -16,14 +18,14 @@ namespace logging
extern const std::map<std::string, std::vector<std::string>> g_errMetaMap;
extern const std::map<std::string, level> g_errLevelMap;
-using DeleteAllIface = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
+using CreateIface = sdbusplus::xyz::openbmc_project::Logging::server::Create;
+using DeleteAllIface =
+ sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll;
namespace details
{
-
-template <typename T>
-using ServerObject = typename sdbusplus::server::object::object<T>;
+template <typename... T>
+using ServerObject = typename sdbusplus::server::object::object<T...>;
using ManagerIface =
sdbusplus::xyz::openbmc_project::Logging::Internal::server::Manager;
@@ -124,6 +126,21 @@ class Manager : public details::ServerObject<details::ManagerIface>
return busLog;
}
+ /** @brief Creates an event log
+ *
+ * This is an alternative to the _commit() API. It doesn't use
+ * the journal to look up event log metadata like _commit does.
+ *
+ * @param[in] errMsg - The error exception message associated with the
+ * error log to be committed.
+ * @param[in] severity - level of the error
+ * @param[in] additionalData - The AdditionalData property for the error
+ */
+ void create(
+ const std::string& message,
+ sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level severity,
+ const std::map<std::string, std::string>& additionalData);
+
private:
/*
* @fn _commit()
@@ -199,11 +216,13 @@ class Manager : public details::ServerObject<details::ManagerIface>
} // namespace internal
/** @class Manager
- * @brief Implementation for delete all error log entries.
+ * @brief Implementation for deleting all error log entries and
+ * creating new logs.
* @details A concrete implementation for the
- * xyz.openbmc_project.Collection.DeleteAll
+ * xyz.openbmc_project.Collection.DeleteAll and
+ * xyz.openbmc_project.Logging.Create interfaces.
*/
-class Manager : public DeleteAllIface
+class Manager : public details::ServerObject<DeleteAllIface, CreateIface>
{
public:
Manager() = delete;
@@ -222,7 +241,8 @@ class Manager : public DeleteAllIface
*/
Manager(sdbusplus::bus::bus& bus, const std::string& path,
internal::Manager& manager) :
- DeleteAllIface(bus, path.c_str(), true),
+ details::ServerObject<DeleteAllIface, CreateIface>(bus, path.c_str(),
+ true),
manager(manager){};
/** @brief Delete all d-bus objects.
@@ -232,6 +252,21 @@ class Manager : public DeleteAllIface
manager.eraseAll();
}
+ /** @brief D-Bus method call implementation to create an event log.
+ *
+ * @param[in] errMsg - The error exception message associated with the
+ * error log to be committed.
+ * @param[in] severity - Level of the error
+ * @param[in] additionalData - The AdditionalData property for the error
+ */
+ void create(
+ std::string message,
+ sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level severity,
+ std::map<std::string, std::string> additionalData) override
+ {
+ manager.create(message, severity, additionalData);
+ }
+
private:
/** @brief This is a reference to manager object */
internal::Manager& manager;
OpenPOWER on IntegriCloud