summaryrefslogtreecommitdiffstats
path: root/elog_watch.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'elog_watch.hpp')
-rw-r--r--elog_watch.hpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/elog_watch.hpp b/elog_watch.hpp
new file mode 100644
index 0000000..cfdf41a
--- /dev/null
+++ b/elog_watch.hpp
@@ -0,0 +1,67 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
+#include "config.h"
+
+#include "dump_manager.hpp"
+
+namespace phosphor
+{
+namespace dump
+{
+namespace elog
+{
+
+using IMgr = phosphor::dump::internal::Manager;
+
+/** @class Watch
+ * @brief Adds d-bus signal based watch for elog commit.
+ * @details This implements methods for watching for InternalFailure
+ * type error message and call appropriate function to initiate dump
+ */
+class Watch
+{
+ public:
+ Watch() = delete;
+ ~Watch() = default;
+ Watch(const Watch&) = delete;
+ Watch& operator=(const Watch&) = delete;
+ Watch(Watch&&) = default;
+ Watch& operator=(Watch&&) = default;
+
+ /** @brief constructs watch for elog commits.
+ * @param[in] bus - The Dbus bus object
+ * @param[in] intMgr - Dump internal Manager object
+ */
+ Watch(sdbusplus::bus::bus& bus, IMgr& iMgr):
+ iMgr(iMgr),
+ elogMatch(
+ bus,
+ sdbusplus::bus::match::rules::interfacesAdded() +
+ sdbusplus::bus::match::rules::path_namespace(
+ OBJ_LOGGING),
+ std::bind(std::mem_fn(&Watch::callback),
+ this, std::placeholders::_1))
+ {
+ //Do nothing
+ }
+ private:
+
+ /** @brief Callback function for error log commit.
+ * @details InternalError type error message initiates
+ * Internal error type dump request.
+ * @param[in] msg - Data associated with subscribed signal
+ */
+ void callback(sdbusplus::message::message& msg);
+
+ /** @brief Dump internal Manager object. */
+ IMgr& iMgr;
+
+ /** @brief sdbusplus signal match for elog commit */
+ sdbusplus::bus::match_t elogMatch;
+};
+
+}//namespace elog
+}//namespace dump
+}//namespace phosphor
OpenPOWER on IntegriCloud