Enable `lg2` logs to be printed to stderr in test

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: Ie4922b3bf6adeeb1e6dbe8db7e76ed8ae605d754
diff --git a/util/log.hpp b/util/log.hpp
new file mode 100644
index 0000000..14def78
--- /dev/null
+++ b/util/log.hpp
@@ -0,0 +1,14 @@
+#pragma once
+
+// C++20 projects should use `lg2` over `log`, when possible. See the following
+// for details on structured logging:
+//   https://github.com/openbmc/phosphor-logging/blob/master/docs/structured-logging.md
+
+#include <phosphor-logging/lg2.hpp>
+
+// This allows for easier use of string literals (i.e. `"foo"s`). See the
+// following for details:
+//   https://en.cppreference.com/w/cpp/string/basic_string/operator%22%22s
+
+#include <string>
+using namespace std::string_literals;
diff --git a/util/pdbg-no-sim.cpp b/util/pdbg-no-sim.cpp
index 87b49cf..d7b7f90 100644
--- a/util/pdbg-no-sim.cpp
+++ b/util/pdbg-no-sim.cpp
@@ -13,6 +13,7 @@
 #include <libpdbg_sbe.h>
 }
 
+#include <util/log.hpp>
 #include <util/pdbg.hpp>
 #include <util/trace.hpp>
 
@@ -68,8 +69,10 @@
 
     if (0 != rc)
     {
-        trace::err("SCOM read failure: target=%s addr=0x%0" PRIx64,
-                   getPath(i_target), i_addr);
+        lg2::error(
+            "SCOM read failure: target={SCOM_TARGET} addr={SCOM_ADDRESS}",
+            "SCOM_TARGET", getPath(i_target), "SCOM_ADDRESS",
+            (lg2::hex | lg2::field64), i_addr, "SCOM_ACCESS_RC", rc);
     }
 
     return rc;
@@ -86,8 +89,10 @@
 
     if (0 != rc)
     {
-        trace::err("CFAM read failure: target=%s addr=0x%08x",
-                   getPath(i_target), i_addr);
+        lg2::error(
+            "CFAM read failure: target={CFAM_TARGET} addr={CFAM_ADDRESS}",
+            "CFAM_TARGET", getPath(i_target), "CFAM_ADDRESS",
+            (lg2::hex | lg2::field32), i_addr, "CFAM_ACCESS_RC", rc);
     }
 
     return rc;