PEL: Use lg2 in DataInterface files
Modernize it a bit and it makes it easier to see debug traces which can
be done by just running the daemon from the command line.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ic0416222e29be0c6687b6d31cb6ca4feae2ad619
diff --git a/extensions/openpower-pels/data_interface.cpp b/extensions/openpower-pels/data_interface.cpp
index a74a840..9850a9b 100644
--- a/extensions/openpower-pels/data_interface.cpp
+++ b/extensions/openpower-pels/data_interface.cpp
@@ -21,7 +21,7 @@
#include <fmt/format.h>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/State/BMC/server.hpp>
#include <xyz/openbmc_project/State/Boot/Progress/server.hpp>
@@ -109,7 +109,6 @@
using namespace sdbusplus::xyz::openbmc_project::State::Boot::server;
using namespace sdbusplus::xyz::openbmc_project::State::server;
-using namespace phosphor::logging;
namespace match_rules = sdbusplus::bus::match::rules;
const DBusInterfaceList hotplugInterfaces{interface::invFan,
@@ -163,10 +162,8 @@
[this](const auto& value) {
if (std::get<bool>(value) != this->_sendPELsToHost)
{
- log<level::INFO>(
- fmt::format("The send PELs to host setting changed to {}",
- std::get<bool>(value))
- .c_str());
+ lg2::info("The send PELs to host setting changed to {VAL}", "VAL",
+ std::get<bool>(value));
}
this->_sendPELsToHost = std::get<bool>(value);
}));
@@ -339,10 +336,9 @@
}
catch (const std::exception& e)
{
- log<level::WARNING>(fmt::format("Failed reading Model property from "
- "Interface: {} exception: {}",
- interface::invAsset, e.what())
- .c_str());
+ lg2::warning("Failed reading Model property from "
+ "interface: {IFACE} exception: {ERROR}",
+ "IFACE", interface::invAsset, "ERROR", e);
}
return model;
@@ -365,11 +361,9 @@
}
catch (const std::exception& e)
{
- log<level::WARNING>(
- fmt::format("Failed reading SerialNumber property from "
- "Interface: {} exception: {}",
- interface::invAsset, e.what())
- .c_str());
+ lg2::warning("Failed reading SerialNumber property from "
+ "interface: {IFACE} exception: {ERROR}",
+ "IFACE", interface::invAsset, "ERROR", e);
}
return sn;
@@ -395,11 +389,9 @@
}
catch (const std::exception& e)
{
- log<level::WARNING>(
- fmt::format("Failed reading Motherboard CCIN property from "
- "Interface: {} exception: {}",
- interface::viniRecordVPD, e.what())
- .c_str());
+ lg2::warning("Failed reading Motherboard CCIN property from "
+ "interface: {IFACE} exception: {ERROR}",
+ "IFACE", interface::viniRecordVPD, "ERROR", e);
}
return ccin;
@@ -424,11 +416,9 @@
}
catch (const std::exception& e)
{
- log<level::WARNING>(
- fmt::format("Failed reading System IM property from "
- "Interface: {} exception: {}",
- interface::vsbpRecordVPD, e.what())
- .c_str());
+ lg2::warning("Failed reading System IM property from "
+ "interface: {IFACE} exception: {ERROR}",
+ "IFACE", interface::vsbpRecordVPD, "ERROR", e);
}
return systemIM;
@@ -659,11 +649,9 @@
}
catch (const std::exception& e)
{
- log<level::WARNING>(
- fmt::format("Failed reading QuiesceOnHwError property from "
- "Interface: {} exception: {}",
- interface::logSetting, e.what())
- .c_str());
+ lg2::warning("Failed reading QuiesceOnHwError property from "
+ "interface: {IFACE} exception: {ERROR}",
+ "IFACE", interface::logSetting, "ERROR", e);
}
return ret;
@@ -761,12 +749,10 @@
// mentioned above. Ignoring the error.
if (errName != SD_BUS_ERROR_TIMEOUT)
{
- log<level::ERR>(
- fmt::format("GUARD D-Bus call exception"
- "OBJPATH={}, INTERFACE={}, EXCEPTION={}",
- object_path::hwIsolation,
- interface::hwIsolationCreate, e.what())
- .c_str());
+ lg2::error("GUARD D-Bus call exception. Path={PATH}, "
+ "interface = {IFACE}, exception = {ERROR}",
+ "PATH", object_path::hwIsolation, "IFACE",
+ interface::hwIsolationCreate, "ERROR", e);
}
}
}
@@ -910,9 +896,7 @@
}
catch (const sdbusplus::exception_t& e)
{
- log<level::WARNING>(
- fmt::format("Failed getting FRU paths to watch: {}", e.what())
- .c_str());
+ lg2::warning("Failed getting FRU paths to watch: {ERROR}", "ERROR", e);
}
}
@@ -995,14 +979,13 @@
}
catch (const sdbusplus::exception_t& e)
{
- log<level::DEBUG>(fmt::format("Could not get location code for {}: {}",
- path, e.what())
- .c_str());
+ lg2::debug("Could not get location code for {PATH}: {ERROR}", "PATH",
+ path, "ERROR", e);
return;
}
- log<level::DEBUG>(
- fmt::format("Detected FRU {} ({}) present ", path, locCode).c_str());
+ lg2::debug("Detected FRU {PATH} ({LOC}) present ", "PATH", path, "LOC",
+ locCode);
// Tell the subscribers.
setFruPresent(locCode);
diff --git a/extensions/openpower-pels/data_interface.hpp b/extensions/openpower-pels/data_interface.hpp
index 57b1fe5..cd710ce 100644
--- a/extensions/openpower-pels/data_interface.hpp
+++ b/extensions/openpower-pels/data_interface.hpp
@@ -3,7 +3,7 @@
#include "dbus_types.hpp"
#include "dbus_watcher.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>
@@ -507,9 +507,8 @@
}
catch (const std::exception& e)
{
- using namespace phosphor::logging;
- log<level::ERR>("A host state change callback threw "
- "an exception");
+ lg2::error(
+ "A host state change callback threw an exception");
}
}
}
@@ -529,8 +528,7 @@
}
catch (const std::exception& e)
{
- using namespace phosphor::logging;
- log<level::ERR>("A FRU present callback threw an exception");
+ lg2::error("A FRU present callback threw an exception");
}
}
}