Convert from log() to lg2()
Convert from the old log() API to the new lg2() API for logging journal
messages. The new API is simpler to use, and the old API may be
deprecated in the future.
Tested:
* Tested all lg2() calls to verify the resulting journal message was
correct.
* For the complete test plan, see
https://gist.github.com/smccarney/f4ed140bf7a46773b31c76b488e739dc
Change-Id: Ieb46c5d1481ceb51e5b0d51392b1c32596d8eac8
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/src/utils.cpp b/src/utils.cpp
index 316ef31..6b7f602 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -4,14 +4,12 @@
#include <openssl/evp.h>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
#include <fstream>
#include <sstream>
-using namespace phosphor::logging;
-
namespace utils
{
@@ -109,7 +107,7 @@
mapperResponseMsg.read(mapperResponse);
if (mapperResponse.empty())
{
- log<level::ERR>("Error reading mapper response");
+ lg2::error("Error reading mapper response");
throw std::runtime_error("Error reading mapper response");
}
std::vector<std::string> ret;
@@ -122,8 +120,8 @@
}
catch (const sdbusplus::exception_t& ex)
{
- log<level::ERR>("GetObject call failed", entry("PATH=%s", path),
- entry("INTERFACE=%s", interface));
+ lg2::error("GetObject call failed: path={PATH}, interface={INTERFACE}",
+ "PATH", path, "INTERFACE", interface);
throw std::runtime_error("GetObject call failed");
}
}
@@ -132,7 +130,7 @@
{
if (version.empty())
{
- log<level::ERR>("Error version is empty");
+ lg2::error("Error version is empty");
return {};
}
@@ -213,9 +211,10 @@
}
catch (const sdbusplus::exception_t& ex)
{
- log<level::ERR>("GetProperty call failed", entry("PATH=%s", path),
- entry("INTERFACE=%s", interface),
- entry("PROPERTY=%s", propertyName));
+ lg2::error(
+ "GetProperty call failed: path={PATH}, interface={INTERFACE}, "
+ "property={PROPERTY}",
+ "PATH", path, "INTERFACE", interface, "PROPERTY", propertyName);
throw std::runtime_error("GetProperty call failed");
}
}