PEL: Create trace wrapper for peltool
In preparation for peltool being compiled for non-BMC platforms where
libphosphor_logging.so isn't available, create a wrapper function for
tracing so phosphor::logging::log() isn't directly used by the code that
is part of peltool.
For now, the wrapper will just call phosphor::logging::log, but in the
future will be changed to call std::cerr when not on the BMC.
A few files were changed to make use of the new calls. Others will be
done with future commits. Only the code that is built into peltool
needs to use this. This mostly consists of the PEL section classes.
Using this new API does mean no extra data can be stored in the journal
metadata, as the systemd journal may not be available on some platforms
the tool may need to run on, such as AIX. Instead, the data can just be
added into the trace string itself.
In a future commit, the meson.build file will be refactored to remove
the libphosphor_logging dependency so the build will fail if a call to
the phosphor-logging's log() is made within peltool code.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I5e6c235d60466b031e15b157860c07a3f8ddb148
diff --git a/extensions/openpower-pels/extended_user_data.cpp b/extensions/openpower-pels/extended_user_data.cpp
index 6370459..cc7d901 100644
--- a/extensions/openpower-pels/extended_user_data.cpp
+++ b/extensions/openpower-pels/extended_user_data.cpp
@@ -19,15 +19,13 @@
#ifdef PELTOOL
#include "user_data_json.hpp"
#endif
-#include <fmt/format.h>
+#include "trace.hpp"
-#include <phosphor-logging/log.hpp>
+#include <fmt/format.h>
namespace openpower::pels
{
-using namespace phosphor::logging;
-
void ExtendedUserData::unflatten(Stream& stream)
{
stream >> _header;
@@ -60,9 +58,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- fmt::format("Cannot unflatten ExtendedUserData: {}", e.what())
- .c_str());
+ trace::error(
+ fmt::format("Cannot unflatten ExtendedUserData: {}", e.what()));
_valid = false;
}
}
@@ -88,9 +85,8 @@
{
if (header().id != static_cast<uint16_t>(SectionID::extUserData))
{
- log<level::ERR>(
- fmt::format("Invalid ExtendedUserData section ID {}", header().id)
- .c_str());
+ trace::error(
+ fmt::format("Invalid ExtendedUserData section ID {}", header().id));
_valid = false;
}
else