diff options
Diffstat (limited to 'elog_watch.cpp')
-rw-r--r-- | elog_watch.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/elog_watch.cpp b/elog_watch.cpp index 7369783..0a7789c 100644 --- a/elog_watch.cpp +++ b/elog_watch.cpp @@ -4,9 +4,11 @@ #include "dump_internal.hpp" #include "dump_serialize.hpp" +#include "errors_map.hpp" #include "xyz/openbmc_project/Dump/Create/error.hpp" #include <cereal/cereal.hpp> +#include <fstream> #include <phosphor-logging/elog.hpp> #include <sdbusplus/exception.hpp> @@ -22,8 +24,6 @@ namespace elog using namespace phosphor::logging; constexpr auto LOG_PATH = "/xyz/openbmc_project/logging"; -constexpr auto INTERNAL_FAILURE = - "xyz.openbmc_project.Common.Error.InternalFailure"; using Message = std::string; using Attributes = sdbusplus::message::variant<Message>; using AttributeName = std::string; @@ -57,8 +57,6 @@ Watch::Watch(sdbusplus::bus::bus& bus, IMgr& iMgr) : void Watch::addCallback(sdbusplus::message::message& msg) { - using Type = - sdbusplus::xyz::openbmc_project::Dump::Internal::server::Create::Type; using QuotaExceeded = sdbusplus::xyz::openbmc_project::Dump::Create::Error::QuotaExceeded; @@ -112,9 +110,20 @@ void Watch::addCallback(sdbusplus::message::message& msg) return; } - if (data != INTERNAL_FAILURE) + EType errorType; + for (const auto& [type, errorList] : errorMap) + { + auto error = std::find(errorList.begin(), errorList.end(), data); + if (error != errorList.end()) + { + errorType = type; + break; + } + } + + // error not supported in the configuration + if (errorType.empty()) { - // Not a InternalFailure, skip return; } @@ -129,8 +138,13 @@ void Watch::addCallback(sdbusplus::message::message& msg) phosphor::dump::elog::serialize(elogList); - // Call internal create function to initiate dump - iMgr.IMgr::create(Type::InternalFailure, fullPaths); + auto item = std::find_if( + TypeMap.begin(), TypeMap.end(), + [errorType](const auto& err) { return (err.second == errorType); }); + if (item != TypeMap.end()) + { + iMgr.IMgr::create((*item).first, fullPaths); + } } catch (QuotaExceeded& e) { |