Move phosphor-power-supply to lg2
Update the logging API used for files in phosphor-power-supply
from the older phosphor::logging::log style of journal traces
to the newer lg2::log style.
Tested:
* Verified journal traces worked correctly in simulation.
* Verified that formatting and key-value pairs for the
messages were correct via the journalctl command output.
Change-Id: Ib4c031be1e43a1726f8d22215fce2d4ccc330cfa
Signed-off-by: Anwaar Hadi <anwaar.hadi@ibm.com>
diff --git a/phosphor-power-supply/util.cpp b/phosphor-power-supply/util.cpp
index 54f6eb7..73c7ff5 100644
--- a/phosphor-power-supply/util.cpp
+++ b/phosphor-power-supply/util.cpp
@@ -47,7 +47,7 @@
if (!line)
{
- log<level::ERR>("Failed line");
+ lg2::error("Failed line in GPIOInterface::read()");
throw std::runtime_error{std::string{"Failed to find line"}};
}
@@ -61,9 +61,7 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- std::format("Failed to get_value of GPIO line: {}", e.what())
- .c_str());
+ lg2::error("Failed to get_value of GPIO line: {ERROR}", "ERROR", e);
line.release();
throw;
}
@@ -72,8 +70,7 @@
}
catch (const std::exception& e)
{
- log<level::ERR>("Failed to request GPIO line",
- entry("MSG=%s", e.what()));
+ lg2::error("Failed to request GPIO line: {MSG}", "MSG", e);
throw;
}
@@ -86,7 +83,7 @@
if (!line)
{
- log<level::ERR>("Failed line");
+ lg2::error("Failed line in GPIOInterface::write");
throw std::runtime_error{std::string{"Failed to find line"}};
}
@@ -100,8 +97,8 @@
}
catch (std::exception& e)
{
- log<level::ERR>("Failed to set GPIO line", entry("MSG=%s", e.what()),
- entry("VALUE=%d", value));
+ lg2::error("Failed to set GPIO line, MSG={MSG}, VALUE={VALUE}", "MSG",
+ e, "VALUE", value);
throw;
}
}