regulators: Modify Manager to use Services
Modify the Manager class to use the new Services interface.
Tested:
* Verified all journal messages logged by Manager still work.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: Ifaa1dfe67e4ab33ea42e9ee1daf65a5663087a0d
diff --git a/phosphor-regulators/src/manager.cpp b/phosphor-regulators/src/manager.cpp
index 10b9de9..fd8dd01 100644
--- a/phosphor-regulators/src/manager.cpp
+++ b/phosphor-regulators/src/manager.cpp
@@ -19,7 +19,6 @@
#include "chassis.hpp"
#include "config_file_parser.hpp"
#include "exception_utils.hpp"
-#include "journal.hpp"
#include "rule.hpp"
#include "utility.hpp"
@@ -50,7 +49,7 @@
const fs::path testConfigFileDir{"/etc/phosphor-regulators"};
Manager::Manager(sdbusplus::bus::bus& bus, const sdeventplus::Event& event) :
- ManagerObject{bus, objPath, true}, bus{bus}, eventLoop{event}
+ ManagerObject{bus, objPath, true}, bus{bus}, eventLoop{event}, services{bus}
{
/* Temporarily comment out until D-Bus interface is defined and available.
// Subscribe to interfacesAdded signal for filename property
@@ -89,8 +88,8 @@
}
else
{
- journal::logErr("Unable to configure regulator devices: Configuration "
- "file not loaded");
+ services.getJournal().logError("Unable to configure regulator devices: "
+ "Configuration file not loaded");
// TODO: Log error
}
@@ -233,7 +232,8 @@
fs::path pathName = findConfigFile();
// Log info message in journal; config file path is important
- journal::logInfo("Loading configuration file " + pathName.string());
+ services.getJournal().logInfo("Loading configuration file " +
+ pathName.string());
// Parse the config file
std::vector<std::unique_ptr<Rule>> rules{};
@@ -247,8 +247,8 @@
catch (const std::exception& e)
{
// Log error messages in journal
- exception_utils::log(e);
- journal::logErr("Unable to load configuration file");
+ services.getJournal().logError(exception_utils::getMessages(e));
+ services.getJournal().logError("Unable to load configuration file");
// TODO: Create error log entry
}
diff --git a/phosphor-regulators/src/manager.hpp b/phosphor-regulators/src/manager.hpp
index 1763f92..b52489e 100644
--- a/phosphor-regulators/src/manager.hpp
+++ b/phosphor-regulators/src/manager.hpp
@@ -15,6 +15,7 @@
*/
#pragma once
+#include "services.hpp"
#include "system.hpp"
#include <interfaces/manager_interface.hpp>
@@ -60,7 +61,7 @@
* Constructor
* Creates a manager over the regulators.
*
- * @param bus the dbus bus
+ * @param bus the D-Bus bus
* @param event the sdevent event
*/
Manager(sdbusplus::bus::bus& bus, const sdeventplus::Event& event);
@@ -154,7 +155,7 @@
void loadConfigFile();
/**
- * The dbus bus
+ * The D-Bus bus
*/
sdbusplus::bus::bus& bus;
@@ -164,6 +165,11 @@
sdeventplus::Event eventLoop;
/**
+ * System services like error logging and the journal.
+ */
+ BMCServices services;
+
+ /**
* List of event timers
*/
std::vector<Timer> timers{};