diff options
author | Marri Devender Rao <devenrao@in.ibm.com> | 2017-04-04 04:09:02 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-04-12 20:54:46 +0000 |
commit | d41e995d71b14f2c552b4da58eedbe1030cbf002 (patch) | |
tree | 55b50e1407845871c681b03f31922137824efde0 /phosphor-logging | |
parent | 7d0a07ba3205807b5c2f5c84261d7a9cc295decb (diff) | |
download | phosphor-logging-d41e995d71b14f2c552b4da58eedbe1030cbf002.tar.gz phosphor-logging-d41e995d71b14f2c552b4da58eedbe1030cbf002.zip |
Add new report interface
Added new report interface that creates
elog entry and also commits it
Change-Id: I68ebbd25561617774f498be073df4ecb627e0ef9
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
Diffstat (limited to 'phosphor-logging')
-rw-r--r-- | phosphor-logging/elog.hpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/phosphor-logging/elog.hpp b/phosphor-logging/elog.hpp index eec5679..041303e 100644 --- a/phosphor-logging/elog.hpp +++ b/phosphor-logging/elog.hpp @@ -147,6 +147,35 @@ void elog(Args... i_args) throw T(); } +/** @fn report() + * @brief Create a journal log entry based on predefined + * error log information and commit the error + * @tparam T - exception + * @param[in] i_args - Metadata fields to be added to the journal entry + */ +template <typename T, typename ...Args> +void report(Args... i_args) +{ + //validate if the exception is derived from sdbusplus::exception. + static_assert( + std::is_base_of<sdbusplus::exception::exception, T>::value, + "T must be a descendant of sdbusplus::exception::exception" + ); + + // Validate the caller passed in the required parameters + static_assert(std::is_same<typename details:: + map_exception_type_t<T>::metadata_types, + std::tuple< + details::deduce_entry_type_t<Args>...>> + ::value, + "You are not passing in required arguments for this error"); + + log<details::map_exception_type_t<T>::L>( + T::errDesc, + details::deduce_entry_type<Args>{i_args}.get()...); + + commit<T>(); +} } // namespace logging } // namespace phosphor |