Move tracing over to phosphor-logging interfaces
Change-Id: I1af70670f4e6e941c2656cfc2877789903e9aec0
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index 1b09b16..e16d0de 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -2,6 +2,7 @@
#include <map>
#include <string>
#include <systemd/sd-bus.h>
+#include <log.hpp>
#include "host_state_manager.hpp"
namespace phosphor
@@ -14,6 +15,8 @@
// When you see server:: you know we're referencing our base class
namespace server = sdbusplus::xyz::openbmc_project::State::server;
+using namespace phosphor::logging;
+
/* Map a transition to it's systemd target */
const std::map<server::Host::Transition,std::string> SYSTEMD_TARGET_TABLE =
{
@@ -53,13 +56,17 @@
if(sysState == "HOST_BOOTED")
{
- std::cout << "HOST is BOOTED " << sysState << std::endl;
+ log<level::INFO>("Initial Host State will be Running",
+ entry("CURRENT_HOST_STATE=%s",
+ convertForMessage(HostState::Running).c_str()));
currentHostState(HostState::Running);
requestedHostTransition(Transition::On);
}
else
{
- std::cout << "HOST is not BOOTED " << sysState << std::endl;
+ log<level::INFO>("Initial Host State will be Off",
+ entry("CURRENT_HOST_STATE=%s",
+ convertForMessage(HostState::Off).c_str()));
currentHostState(HostState::Off);
requestedHostTransition(Transition::Off);
}
@@ -95,8 +102,6 @@
auto sdPlusMsg = sdbusplus::message::message(msg);
sdPlusMsg.read(newState);
- std::cout << "The System State has changed to " << newState << std::endl;
-
auto it = SYS_HOST_STATE_TABLE.find(newState);
if(it != SYS_HOST_STATE_TABLE.end())
{
@@ -111,27 +116,24 @@
(hostInst->server::Host::requestedHostTransition() ==
Transition::Reboot))
{
- std::cout << "Reached intermediate state, going to next" <<
- std::endl;
+ log<level::DEBUG>("Reached intermediate state, going to next");
hostInst->executeTransition(server::Host::Transition::On);
}
else
{
- std::cout << "Reached Final State " << newState << std::endl;
+ log<level::DEBUG>("Reached final state");
}
}
- else
- {
- std::cout << "Not a relevant state change for host" << std::endl;
- }
return 0;
}
Host::Transition Host::requestedHostTransition(Transition value)
{
- std::cout << "Someone is setting the RequestedHostTransition field"
- << std::endl;
+ log<level::INFO>(
+ "Host State transaction request",
+ entry("REQUESTED_HOST_TRANSITION=%s",
+ convertForMessage(value).c_str()));
Transition tranReq = value;
if(value == server::Host::Transition::Reboot)
@@ -151,13 +153,14 @@
}
executeTransition(tranReq);
- std::cout << "Transition executed with success" << std::endl;
return server::Host::requestedHostTransition(value);
}
Host::HostState Host::currentHostState(HostState value)
{
- std::cout << "Changing HostState" << std::endl;
+ log<level::INFO>("Change to Host State",
+ entry("CURRENT_HOST_STATE=%s",
+ convertForMessage(value).c_str()));
return server::Host::currentHostState(value);
}