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/tools/peltool.cpp b/extensions/openpower-pels/tools/peltool.cpp
index 3acfd8a..0e24850 100644
--- a/extensions/openpower-pels/tools/peltool.cpp
+++ b/extensions/openpower-pels/tools/peltool.cpp
@@ -21,14 +21,15 @@
 #include "../pel.hpp"
 #include "../pel_types.hpp"
 #include "../pel_values.hpp"
+#include "trace.hpp"
 
 #include <Python.h>
+#include <fmt/format.h>
 
 #include <CLI/CLI.hpp>
 #include <bitset>
 #include <fstream>
 #include <iostream>
-#include <phosphor-logging/log.hpp>
 #include <regex>
 #include <string>
 #include <xyz/openbmc_project/Common/File/error.hpp>
@@ -36,7 +37,6 @@
 #include "config_main.h"
 
 namespace fs = std::filesystem;
-using namespace phosphor::logging;
 using namespace openpower::pels;
 namespace file_error = sdbusplus::xyz::openbmc_project::Common::File::Error;
 namespace message = openpower::pels::message;
@@ -320,8 +320,7 @@
         std::vector<uint8_t> data = getFileData(fileName);
         if (data.empty())
         {
-            log<level::ERR>("Empty PEL file",
-                            entry("FILENAME=%s", fileName.c_str()));
+            trace::error(fmt::format("Empty PEL file {}", fileName));
             return listStr;
         }
         PEL pel{data};
@@ -444,9 +443,8 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("Hit exception while reading PEL File",
-                        entry("FILENAME=%s", fileName.c_str()),
-                        entry("ERROR=%s", e.what()));
+        trace::error(fmt::format("Hit exception when reading PEL file {}: {}",
+                                 fileName, e.what()));
     }
     return listStr;
 }
@@ -648,7 +646,7 @@
  */
 void deleteAllPELs()
 {
-    log<level::INFO>("peltool deleting all event logs");
+    trace::info("peltool deleting all event logs");
 
     for (const auto& entry : fs::directory_iterator(pelLogDir()))
     {