PEL: Use lg2 in PEL class
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ibc052f66eb0e5d8429a3da45569fe09931b43b49
diff --git a/extensions/openpower-pels/pel.cpp b/extensions/openpower-pels/pel.cpp
index d0a187c..78a28e6 100644
--- a/extensions/openpower-pels/pel.cpp
+++ b/extensions/openpower-pels/pel.cpp
@@ -40,7 +40,7 @@
#include <sys/stat.h>
#include <unistd.h>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <iostream>
@@ -49,7 +49,6 @@
namespace pels
{
namespace pv = openpower::pels::pel_values;
-using namespace phosphor::logging;
constexpr auto unknownValue = "Unknown";
@@ -189,8 +188,7 @@
{
for (const auto& message : msgs)
{
- std::string entry = name + ": " + message;
- log<level::INFO>(entry.c_str());
+ lg2::info("{NAME}: {MSG}", "NAME", name, "MSG", message);
}
}
}
@@ -266,7 +264,7 @@
if (!valid())
{
- log<level::WARNING>("Unflattening an invalid PEL");
+ lg2::warning("Unflattening an invalid PEL");
}
_ph->flatten(pelData);
@@ -473,12 +471,13 @@
}
else
{
- log<level::WARNING>(
- "Could not shrink UserData section. Dropping",
- entry("SECTION_SIZE=%d\n", userData->header().size),
- entry("COMPONENT_ID=0x%02X", userData->header().componentID),
- entry("SUBTYPE=0x%X", userData->header().subType),
- entry("VERSION=0x%X", userData->header().version));
+ lg2::warning("Could not shrink UserData section. Dropping. "
+ "Section size = {SSIZE}, Component ID = {COMP_ID}, "
+ "Subtype = {SUBTYPE}, Version = {VERSION}",
+ "SSIZE", userData->header().size, "COMP_ID",
+ userData->header().componentID, "SUBTYPE",
+ userData->header().subType, "VERSION",
+ userData->header().version);
return false;
}
}
@@ -652,9 +651,7 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- fmt::format("Failed during journal collection: {}", e.what())
- .c_str());
+ lg2::error("Failed during journal collection: {ERROR}", "ERROR", e);
}
}
else if (std::holds_alternative<message::AppCaptureList>(jc))
@@ -673,10 +670,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- fmt::format("Failed during journal collection: {}",
- e.what())
- .c_str());
+ lg2::error("Failed during journal collection: {ERROR}", "ERROR",
+ e);
}
}
}
@@ -691,11 +686,10 @@
// check here.
if (buffer.size() > _maxPELSize)
{
- log<level::WARNING>(
- "Journal UserData section does not fit in PEL, dropping");
- log<level::WARNING>(fmt::format("PEL size = {}, data size = {}",
- size(), buffer.size())
- .c_str());
+ lg2::warning(
+ "Journal UserData section does not fit in PEL, dropping. "
+ "PEL size = {PEL_SIZE}, data size = {DATA_SIZE}",
+ "PEL_SIZE", size(), "DATA_SIZE", buffer.size());
continue;
}
@@ -718,11 +712,10 @@
{
// Don't attempt to shrink here since we'd be dropping the
// most recent journal entries which would be confusing.
- log<level::WARNING>(
- "Journal UserData section does not fit in PEL, dropping");
- log<level::WARNING>(fmt::format("PEL size = {}, UserData size = {}",
- size(), ud->header().size)
- .c_str());
+ lg2::warning(
+ "Journal UserData section does not fit in PEL, dropping. "
+ "PEL size = {PEL_SIZE}, data size = {DATA_SIZE}",
+ "PEL_SIZE", size(), "DATA_SIZE", buffer.size());
ud.reset();
continue;
}
@@ -883,14 +876,14 @@
if (r != 0)
{
auto e = errno;
- log<level::ERR>("Could not get FFDC file size from FD",
- entry("ERRNO=%d", e));
+ lg2::error("Could not get FFDC file size from FD, errno = {ERRNO}",
+ "ERRNO", e);
return data;
}
if (0 == s.st_size)
{
- log<level::ERR>("FFDC file is empty");
+ lg2::error("FFDC file is empty");
return data;
}
@@ -902,8 +895,8 @@
if (r == -1)
{
auto e = errno;
- log<level::ERR>("Could not seek to beginning of FFDC file",
- entry("ERRNO=%d", e));
+ lg2::error("Could not seek to beginning of FFDC file, errno = {ERRNO}",
+ "ERRNO", e);
return data;
}
@@ -911,13 +904,13 @@
if (r == -1)
{
auto e = errno;
- log<level::ERR>("Could not read FFDC file", entry("ERRNO=%d", e));
+ lg2::error("Could not read FFDC file, errno = {ERRNO}", "ERRNO", e);
}
else if (r != s.st_size)
{
- log<level::WARNING>("Could not read full FFDC file",
- entry("FILE_SIZE=%d", s.st_size),
- entry("SIZE_READ=%d", r));
+ lg2::warning("Could not read full FFDC file. "
+ "File size = {FSIZE}, Size read = {SIZE_READ}",
+ "FSIZE", s.st_size, "SIZE_READ", r);
}
return data;