regulators: Modify monitorSensors() to use Services

Modify the monitorSensors() method in the System, Chassis, Device, and
Rail classes to have a new first parameter: Services& services.

Modify SensorMonitoring::execute() to log messages using the new
Journal interface.

Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I05820cfa94bc3d15dee7a1714a3d253720aa7f92
diff --git a/phosphor-regulators/test/rail_tests.cpp b/phosphor-regulators/test/rail_tests.cpp
index 190e48e..d5f8db2 100644
--- a/phosphor-regulators/test/rail_tests.cpp
+++ b/phosphor-regulators/test/rail_tests.cpp
@@ -18,7 +18,6 @@
 #include "configuration.hpp"
 #include "device.hpp"
 #include "i2c_interface.hpp"
-#include "journal.hpp"
 #include "mock_action.hpp"
 #include "mock_journal.hpp"
 #include "mock_services.hpp"
@@ -217,6 +216,12 @@
 {
     // Test where SensorMonitoring was not specified in constructor
     {
+        // Create mock services.  No logging should occur.
+        MockServices services{};
+        MockJournal& journal = services.getMockJournal();
+        EXPECT_CALL(journal, logDebug(A<const std::string&>())).Times(0);
+        EXPECT_CALL(journal, logError(A<const std::string&>())).Times(0);
+
         // Create mock I2CInterface.  A two-byte read should NOT occur.
         std::unique_ptr<i2c::MockedI2CInterface> i2cInterface =
             std::make_unique<i2c::MockedI2CInterface>();
@@ -250,15 +255,18 @@
         chassisVec.emplace_back(std::move(chassis));
         System system{std::move(rules), std::move(chassisVec)};
 
-        // Call monitorSensors().  Should do nothing.
-        journal::clear();
-        railPtr->monitorSensors(system, *chassisPtr, *devicePtr);
-        EXPECT_EQ(journal::getDebugMessages().size(), 0);
-        EXPECT_EQ(journal::getErrMessages().size(), 0);
+        // Call monitorSensors().
+        railPtr->monitorSensors(services, system, *chassisPtr, *devicePtr);
     }
 
     // Test where SensorMonitoring was specified in constructor
     {
+        // Create mock services.  No logging should occur.
+        MockServices services{};
+        MockJournal& journal = services.getMockJournal();
+        EXPECT_CALL(journal, logDebug(A<const std::string&>())).Times(0);
+        EXPECT_CALL(journal, logError(A<const std::string&>())).Times(0);
+
         // Create PMBusReadSensorAction
         pmbus_utils::SensorValueType type{pmbus_utils::SensorValueType::iout};
         uint8_t command = 0x8C;
@@ -313,10 +321,7 @@
         System system{std::move(rules), std::move(chassisVec)};
 
         // Call monitorSensors().
-        journal::clear();
-        railPtr->monitorSensors(system, *chassisPtr, *devicePtr);
-        EXPECT_EQ(journal::getDebugMessages().size(), 0);
-        EXPECT_EQ(journal::getErrMessages().size(), 0);
+        railPtr->monitorSensors(services, system, *chassisPtr, *devicePtr);
     }
 }