regulators: Add phase faults to ErrorLogging
Enhance the ErrorLogging class hierarchy to log phase fault errors.
Support specifying additional error data that may have been collected
from the device.
Tested:
* Logged an N phase fault error
* Logged an N+1 phase fault error
* Verified mock logPhaseFault() method could be used in a gtest.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I67efb7e16bb3fc5a071ccc60a949bba30daf3e78
diff --git a/phosphor-regulators/src/error_logging.cpp b/phosphor-regulators/src/error_logging.cpp
index bc3d388..9ebce1a 100644
--- a/phosphor-regulators/src/error_logging.cpp
+++ b/phosphor-regulators/src/error_logging.cpp
@@ -86,6 +86,19 @@
additionalData, journal);
}
+void DBusErrorLogging::logPhaseFault(
+ Entry::Level severity, Journal& journal, PhaseFaultType type,
+ const std::string& inventoryPath,
+ std::map<std::string, std::string> additionalData)
+{
+ std::string message =
+ (type == PhaseFaultType::n)
+ ? "xyz.openbmc_project.Power.Regulators.Error.PhaseFault.N"
+ : "xyz.openbmc_project.Power.Regulators.Error.PhaseFault.NPlus1";
+ additionalData.emplace("CALLOUT_INVENTORY_PATH", inventoryPath);
+ logError(message, severity, additionalData, journal);
+}
+
void DBusErrorLogging::logPMBusError(Entry::Level severity, Journal& journal,
const std::string& inventoryPath)
{
diff --git a/phosphor-regulators/src/error_logging.hpp b/phosphor-regulators/src/error_logging.hpp
index ba95561..e6abfbe 100644
--- a/phosphor-regulators/src/error_logging.hpp
+++ b/phosphor-regulators/src/error_logging.hpp
@@ -17,6 +17,7 @@
#include "ffdc_file.hpp"
#include "journal.hpp"
+#include "phase_fault.hpp"
#include "xyz/openbmc_project/Logging/Create/server.hpp"
#include "xyz/openbmc_project/Logging/Entry/server.hpp"
@@ -98,6 +99,23 @@
virtual void logInternalError(Entry::Level severity, Journal& journal) = 0;
/**
+ * Log a phase fault error.
+ *
+ * This error is logged when a regulator has lost a redundant phase.
+ *
+ * @param severity severity level
+ * @param journal system journal
+ * @param type phase fault type
+ * @param inventoryPath D-Bus inventory path of the device where the error
+ * occurred
+ * @param additionalData additional error data (if any)
+ */
+ virtual void
+ logPhaseFault(Entry::Level severity, Journal& journal,
+ PhaseFaultType type, const std::string& inventoryPath,
+ std::map<std::string, std::string> additionalData) = 0;
+
+ /**
* Log a PMBus error.
*
* This error is logged when the I2C communication was successful, but the
@@ -168,6 +186,12 @@
virtual void logInternalError(Entry::Level severity,
Journal& journal) override;
+ /** @copydoc ErrorLogging::logPhaseFault() */
+ virtual void logPhaseFault(
+ Entry::Level severity, Journal& journal, PhaseFaultType type,
+ const std::string& inventoryPath,
+ std::map<std::string, std::string> additionalData) override;
+
/** @copydoc ErrorLogging::logPMBusError() */
virtual void logPMBusError(Entry::Level severity, Journal& journal,
const std::string& inventoryPath) override;
diff --git a/phosphor-regulators/test/mock_error_logging.hpp b/phosphor-regulators/test/mock_error_logging.hpp
index db75a37..839bf46 100644
--- a/phosphor-regulators/test/mock_error_logging.hpp
+++ b/phosphor-regulators/test/mock_error_logging.hpp
@@ -16,6 +16,7 @@
#pragma once
#include "error_logging.hpp"
+#include "phase_fault.hpp"
#include <gmock/gmock.h>
@@ -52,6 +53,12 @@
MOCK_METHOD(void, logInternalError,
(Entry::Level severity, Journal& journal), (override));
+ MOCK_METHOD(void, logPhaseFault,
+ (Entry::Level severity, Journal& journal, PhaseFaultType type,
+ const std::string& inventoryPath,
+ (std::map<std::string, std::string> additionalData)),
+ (override));
+
MOCK_METHOD(void, logPMBusError,
(Entry::Level severity, Journal& journal,
const std::string& inventoryPath),