diff options
| author | Andrew Geissler <andrewg@us.ibm.com> | 2016-12-13 15:32:22 -0600 |
|---|---|---|
| committer | Andrew Geissler <andrewg@us.ibm.com> | 2017-01-12 14:20:13 -0600 |
| commit | 1e3bf946f321fecc41690cb50e047357308b9d0c (patch) | |
| tree | f431d07966ae208781a54e409188509f325071cf | |
| parent | 1cb8b7070f44470953f61f7143b6717b8366d9c8 (diff) | |
| download | phosphor-state-manager-1e3bf946f321fecc41690cb50e047357308b9d0c.tar.gz phosphor-state-manager-1e3bf946f321fecc41690cb50e047357308b9d0c.zip | |
Move tracing over to phosphor-logging interfaces
Change-Id: I1af70670f4e6e941c2656cfc2877789903e9aec0
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
| -rw-r--r-- | configure.ac | 4 | ||||
| -rw-r--r-- | host_state_manager.cpp | 33 |
2 files changed, 21 insertions, 16 deletions
diff --git a/configure.ac b/configure.ac index 847d7e5..24b0899 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,8 @@ AC_DEFINE_UNQUOTED([OBJPATH], ["$OBJPATH"], [The host state manager Dbus root]) # Check for header files. AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd developement package required])]) AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...openbmc/sdbusplus package required])]) +AC_CHECK_HEADER(log.hpp, ,[AC_MSG_ERROR([Could not find log.hpp...openbmc/phosphor-logging package required])]) + AC_CONFIG_FILES([Makefile]) -AC_OUTPUT
\ No newline at end of file +AC_OUTPUT 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 @@ namespace manager // 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 @@ void Host::determineInitialState() 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 @@ int Host::handleSysStateChange(sd_bus_message *msg, void *usrData, 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 @@ int Host::handleSysStateChange(sd_bus_message *msg, void *usrData, (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 @@ Host::Transition Host::requestedHostTransition(Transition value) } 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); } |

