Attention handler trace message refactor

Signed-off-by: austinfcui <austinfcui@gmail.com>
Change-Id: If86af8fb88b0ce15f6a626676a412a5cee88acc0
diff --git a/attn/attn_logging.cpp b/attn/attn_logging.cpp
index 94a54bd..9de91f2 100644
--- a/attn/attn_logging.cpp
+++ b/attn/attn_logging.cpp
@@ -7,23 +7,11 @@
 #include <attn/attn_logging.hpp>
 #include <attn/pel/pel_minimal.hpp>
 #include <phosphor-logging/log.hpp>
+#include <util/trace.hpp>
 
 namespace attn
 {
 
-/** @brief Journal entry of type INFO using phosphor logging */
-template <>
-void trace<INFO>(const char* i_message)
-{
-    phosphor::logging::log<phosphor::logging::level::INFO>(i_message);
-}
-
-template <>
-void trace<ERROR>(const char* i_message)
-{
-    phosphor::logging::log<phosphor::logging::level::ERR>(i_message);
-}
-
 /** @brief Tuple containing information about ffdc files */
 using FFDCTuple =
     std::tuple<util::FFDCFormat, uint8_t, uint8_t, sdbusplus::message::unix_fd>;
@@ -69,11 +57,8 @@
     size_t numBytes = write(fd, static_cast<char*>(i_buffer), i_size);
     if (i_size != numBytes)
     {
-        std::stringstream traceMsg;
-        traceMsg << file.getPath().c_str() << " only " << (int)numBytes
-                 << " of " << (int)i_size << " bytes written";
-        auto strobj = traceMsg.str();
-        trace<level::ERROR>(strobj.c_str());
+        trace::err("%s only %u of %u bytes written", file.getPath().c_str(),
+                   numBytes, i_size);
     }
 
     lseek(fd, 0, SEEK_SET);
@@ -110,11 +95,8 @@
         size_t numBytes = write(fd, buffer.c_str(), buffer.size());
         if (buffer.size() != numBytes)
         {
-            std::stringstream traceMsg;
-            traceMsg << file.getPath().c_str() << " only " << (int)numBytes
-                     << " of " << (int)buffer.size() << " bytes written";
-            auto strobj = traceMsg.str();
-            trace<level::ERROR>(strobj.c_str());
+            trace::err("%s only %u of %u bytes written", file.getPath().c_str(),
+                       numBytes, buffer.size());
         }
     }
 
@@ -155,9 +137,8 @@
         }
         catch (const std::exception& e)
         {
-            trace<level::INFO>("createFFDCTraceFiles exception");
-            std::string traceMsg = std::string(e.what(), maxTraceLen);
-            trace<level::INFO>(traceMsg.c_str());
+            trace::inf("createFFDCTraceFiles exception");
+            trace::inf(e.what());
         }
     }
 }
@@ -411,11 +392,8 @@
                 size_t numBytes = read(pelFd, buffer.data(), buffer.size());
                 if (buffer.size() != numBytes)
                 {
-                    std::stringstream traceMsg;
-                    traceMsg << "Error reading event log: " << (int)numBytes
-                             << " of " << (int)buffer.size() << " bytes read";
-                    auto strobj = traceMsg.str();
-                    trace<level::ERROR>(strobj.c_str());
+                    trace::err("Error reading event log: %u of %u bytes read",
+                               numBytes, buffer.size());
                 }
                 else
                 {
@@ -479,8 +457,7 @@
         }
     }
 
-    std::string traceMsg = "TI info size = " + std::to_string(tiInfoSize);
-    trace<level::INFO>(traceMsg.c_str());
+    trace::inf("TI info size = %u", tiInfoSize);
 
     event(EventType::Terminate, i_additionalData,
           createFFDCFiles(i_tiInfoData, tiInfoSize));