blob: cfdf41a4cc11ff5ae5ac6c81b9880b9ff3bfbaf4 [file] [log] [blame]
Jayanth Othayothd0f00642017-09-04 06:26:30 -05001#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include <sdbusplus/server.hpp>
5#include "config.h"
6
7#include "dump_manager.hpp"
8
9namespace phosphor
10{
11namespace dump
12{
13namespace elog
14{
15
16using IMgr = phosphor::dump::internal::Manager;
17
18/** @class Watch
19 * @brief Adds d-bus signal based watch for elog commit.
20 * @details This implements methods for watching for InternalFailure
21 * type error message and call appropriate function to initiate dump
22 */
23class Watch
24{
25 public:
26 Watch() = delete;
27 ~Watch() = default;
28 Watch(const Watch&) = delete;
29 Watch& operator=(const Watch&) = delete;
30 Watch(Watch&&) = default;
31 Watch& operator=(Watch&&) = default;
32
33 /** @brief constructs watch for elog commits.
34 * @param[in] bus - The Dbus bus object
35 * @param[in] intMgr - Dump internal Manager object
36 */
37 Watch(sdbusplus::bus::bus& bus, IMgr& iMgr):
38 iMgr(iMgr),
39 elogMatch(
40 bus,
41 sdbusplus::bus::match::rules::interfacesAdded() +
42 sdbusplus::bus::match::rules::path_namespace(
43 OBJ_LOGGING),
44 std::bind(std::mem_fn(&Watch::callback),
45 this, std::placeholders::_1))
46 {
47 //Do nothing
48 }
49 private:
50
51 /** @brief Callback function for error log commit.
52 * @details InternalError type error message initiates
53 * Internal error type dump request.
54 * @param[in] msg - Data associated with subscribed signal
55 */
56 void callback(sdbusplus::message::message& msg);
57
58 /** @brief Dump internal Manager object. */
59 IMgr& iMgr;
60
61 /** @brief sdbusplus signal match for elog commit */
62 sdbusplus::bus::match_t elogMatch;
63};
64
65}//namespace elog
66}//namespace dump
67}//namespace phosphor