Move phosphor-regulators, tools, base dir to lg2
Update the logging API for files in phosphor-regulators, tools,
and the base directory from the older phosphor::logging::log
style of journal traces to the newer lg2::log style. Also
fix bug involving corruption of string data in PMBus class.
Tested:
* Verified journal traces worked correctly in simulation
and produced correct journalctl key-value pairs.
* Temporarily modified both json configs and source code to
force various messages, and verified their presence in the
journalctl output.
* Verify that change in PMBus class correctly fixed corrupted
string data by building and running a temporary executable
with the change included.
Change-Id: I9c3e380bf2103c5ddc051a5dc90ba2c0d3f38796
Signed-off-by: Anwaar Hadi <anwaar.hadi@ibm.com>
diff --git a/utility.cpp b/utility.cpp
index 0e687dd..c2d7815 100644
--- a/utility.cpp
+++ b/utility.cpp
@@ -51,11 +51,9 @@
{
if (logError)
{
- log<level::ERR>(
- std::string("Error in mapper response for getting service name "
- "PATH=" +
- path + " INTERFACE=" + interface)
- .c_str());
+ lg2::error("Error in mapper response for getting service name "
+ "PATH={PATH} INTERFACE={INTERFACE}",
+ "PATH", path, "INTERFACE", interface);
}
return std::string{};
}
@@ -136,19 +134,13 @@
std::ifstream ifs(path);
if (!ifs.good())
{
- log<level::ERR>(std::string("Unable to open file "
- "PATH=" +
- std::string(path))
- .c_str());
+ lg2::error("Unable to open file PATH={PATH}", "PATH", path);
return nullptr;
}
auto data = json::parse(ifs, nullptr, false);
if (data.is_discarded())
{
- log<level::ERR>(std::string("Failed to parse json "
- "PATH=" +
- std::string(path))
- .c_str());
+ lg2::error("Failed to parse json PATH={PATH}", "PATH", path);
return nullptr;
}
return data;
@@ -197,7 +189,7 @@
}
catch (const std::exception& e)
{
- log<level::INFO>("Failed to get power state.");
+ lg2::info("Failed to get power state.");
}
return state != 0;
}