Gunnar Mills | 9679d43 | 2017-08-03 15:54:43 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | #include <phosphor-logging/elog-errors.hpp> |
| 3 | #include <phosphor-logging/elog.hpp> |
| 4 | #include "callback.hpp" |
| 5 | #include <sdbusplus/exception.hpp> |
| 6 | |
| 7 | namespace phosphor |
| 8 | { |
| 9 | namespace dbus |
| 10 | { |
| 11 | namespace monitoring |
| 12 | { |
| 13 | |
| 14 | /** @class ElogBase |
| 15 | * @brief Elog callback implementation. |
| 16 | * |
| 17 | * The elog callback logs the elog and |
| 18 | * elog metadata. |
| 19 | */ |
| 20 | class ElogBase : public Callback |
| 21 | { |
| 22 | public: |
| 23 | ElogBase(const ElogBase&) = delete; |
| 24 | ElogBase(ElogBase&&) = default; |
| 25 | ElogBase& operator=(const ElogBase&) = delete; |
| 26 | ElogBase& operator=(ElogBase&&) = default; |
| 27 | virtual ~ElogBase() = default; |
| 28 | ElogBase() : |
| 29 | Callback(){} |
| 30 | |
| 31 | /** @brief Callback interface implementation. */ |
| 32 | void operator()() override; |
| 33 | |
| 34 | private: |
| 35 | /** @brief Delegate type specific calls to subclasses. */ |
| 36 | virtual void log() const = 0; |
| 37 | }; |
| 38 | |
| 39 | |
| 40 | /** @class Elog |
| 41 | * @brief C++ type specific logic for the elog callback. |
| 42 | * |
| 43 | * @tparam T - Error log type |
| 44 | */ |
| 45 | template <typename T> |
| 46 | class Elog : public ElogBase |
| 47 | { |
| 48 | public: |
| 49 | Elog(const Elog&) = delete; |
| 50 | Elog(Elog&&) = default; |
| 51 | Elog& operator=(const Elog&) = delete; |
| 52 | Elog& operator=(Elog&&) = default; |
| 53 | ~Elog() = default; |
| 54 | Elog() : |
| 55 | ElogBase() {} |
| 56 | |
| 57 | private: |
| 58 | /** @brief elog interface implementation. */ |
| 59 | void log() const override |
| 60 | { |
| 61 | |
| 62 | using namespace phosphor::logging; |
| 63 | report<T>(); |
| 64 | } |
| 65 | }; |
| 66 | |
| 67 | } // namespace monitoring |
| 68 | } // namespace dbus |
| 69 | } // namespace phosphor |