regulators: Create error log entries
Create error log entries when the following regulator operations fail:
* configuration
* presence detection
* sensor monitoring
* closing I2C devices
Use the recently created error_logging_utils namespace to create error
logs based on caught exceptions.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I25824ecfdaa270abbce92b52bdea0602271d926d
diff --git a/phosphor-regulators/src/configuration.cpp b/phosphor-regulators/src/configuration.cpp
index 04babc7..ddf25ba 100644
--- a/phosphor-regulators/src/configuration.cpp
+++ b/phosphor-regulators/src/configuration.cpp
@@ -20,6 +20,7 @@
#include "action_utils.hpp"
#include "chassis.hpp"
#include "device.hpp"
+#include "error_logging_utils.hpp"
#include "exception_utils.hpp"
#include "rail.hpp"
#include "system.hpp"
@@ -72,7 +73,9 @@
services.getJournal().logError(exception_utils::getMessages(e));
services.getJournal().logError("Unable to configure " + deviceOrRailID);
- // TODO: Create error log entry
+ // Create error log entry
+ error_logging_utils::logError(std::current_exception(),
+ Entry::Level::Warning, services);
}
}
diff --git a/phosphor-regulators/src/device.cpp b/phosphor-regulators/src/device.cpp
index 8ae7afb..08c5174 100644
--- a/phosphor-regulators/src/device.cpp
+++ b/phosphor-regulators/src/device.cpp
@@ -17,6 +17,7 @@
#include "device.hpp"
#include "chassis.hpp"
+#include "error_logging_utils.hpp"
#include "exception_utils.hpp"
#include "system.hpp"
@@ -63,7 +64,9 @@
services.getJournal().logError(exception_utils::getMessages(e));
services.getJournal().logError("Unable to close device " + id);
- // TODO: Create error log entry
+ // Create error log entry
+ error_logging_utils::logError(std::current_exception(),
+ Entry::Level::Notice, services);
}
}
diff --git a/phosphor-regulators/src/presence_detection.cpp b/phosphor-regulators/src/presence_detection.cpp
index 3ed5350..74c241b 100644
--- a/phosphor-regulators/src/presence_detection.cpp
+++ b/phosphor-regulators/src/presence_detection.cpp
@@ -20,6 +20,7 @@
#include "action_utils.hpp"
#include "chassis.hpp"
#include "device.hpp"
+#include "error_logging_utils.hpp"
#include "exception_utils.hpp"
#include "system.hpp"
@@ -54,7 +55,9 @@
services.getJournal().logError("Unable to determine presence of " +
device.getID());
- // TODO: Create error log entry
+ // Create error log entry
+ error_logging_utils::logError(std::current_exception(),
+ Entry::Level::Warning, services);
}
}
diff --git a/phosphor-regulators/src/sensor_monitoring.cpp b/phosphor-regulators/src/sensor_monitoring.cpp
index 1ce1eee..c46ff1a 100644
--- a/phosphor-regulators/src/sensor_monitoring.cpp
+++ b/phosphor-regulators/src/sensor_monitoring.cpp
@@ -20,6 +20,7 @@
#include "action_utils.hpp"
#include "chassis.hpp"
#include "device.hpp"
+#include "error_logging_utils.hpp"
#include "exception_utils.hpp"
#include "rail.hpp"
#include "system.hpp"
@@ -48,7 +49,10 @@
services.getJournal().logError("Unable to monitor sensors for rail " +
rail.getID());
- // TODO: Create error log entry
+ // Create error log entry
+ // TODO: Add ErrorHistory data member and specify as parameter below
+ error_logging_utils::logError(std::current_exception(),
+ Entry::Level::Warning, services);
}
}