diff options
author | Gunnar Mills <gmills@us.ibm.com> | 2017-08-03 15:54:43 -0500 |
---|---|---|
committer | Gunnar Mills <gmills@us.ibm.com> | 2017-08-21 14:26:22 +0000 |
commit | 9679d43ea9a0d2ed89c8eb88851eee838a3e767c (patch) | |
tree | 024788674bebd6a77dbc5053a90ce0d93f6e4d77 /src/elog.hpp | |
parent | 2df09e242d6dd5961d831bd179f73489eba526ed (diff) | |
download | phosphor-dbus-monitor-9679d43ea9a0d2ed89c8eb88851eee838a3e767c.tar.gz phosphor-dbus-monitor-9679d43ea9a0d2ed89c8eb88851eee838a3e767c.zip |
Create new Elog class
Created new Elog callback, which will create an error log.
This is just the base, more to come.
Change-Id: I50c12c8bff0942b5cb027e38d0cc8691e8a241b4
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'src/elog.hpp')
-rw-r--r-- | src/elog.hpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/elog.hpp b/src/elog.hpp new file mode 100644 index 0000000..f138b0b --- /dev/null +++ b/src/elog.hpp @@ -0,0 +1,69 @@ +#pragma once +#include <phosphor-logging/elog-errors.hpp> +#include <phosphor-logging/elog.hpp> +#include "callback.hpp" +#include <sdbusplus/exception.hpp> + +namespace phosphor +{ +namespace dbus +{ +namespace monitoring +{ + +/** @class ElogBase + * @brief Elog callback implementation. + * + * The elog callback logs the elog and + * elog metadata. + */ +class ElogBase : public Callback +{ + public: + ElogBase(const ElogBase&) = delete; + ElogBase(ElogBase&&) = default; + ElogBase& operator=(const ElogBase&) = delete; + ElogBase& operator=(ElogBase&&) = default; + virtual ~ElogBase() = default; + ElogBase() : + Callback(){} + + /** @brief Callback interface implementation. */ + void operator()() override; + + private: + /** @brief Delegate type specific calls to subclasses. */ + virtual void log() const = 0; +}; + + +/** @class Elog + * @brief C++ type specific logic for the elog callback. + * + * @tparam T - Error log type + */ +template <typename T> +class Elog : public ElogBase +{ + public: + Elog(const Elog&) = delete; + Elog(Elog&&) = default; + Elog& operator=(const Elog&) = delete; + Elog& operator=(Elog&&) = default; + ~Elog() = default; + Elog() : + ElogBase() {} + + private: + /** @brief elog interface implementation. */ + void log() const override + { + + using namespace phosphor::logging; + report<T>(); + } +}; + +} // namespace monitoring +} // namespace dbus +} // namespace phosphor |