summaryrefslogtreecommitdiffstats
path: root/phosphor-logging
diff options
context:
space:
mode:
Diffstat (limited to 'phosphor-logging')
-rw-r--r--phosphor-logging/elog.hpp29
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
OpenPOWER on IntegriCloud