Attn: Limit trace length messages

Limit trace length messages specifically for exception messages which
tend to be long.

Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: I50360121541c92b732ffe4502c5084497ebb0357
diff --git a/attn/attn_dbus.cpp b/attn/attn_dbus.cpp
index 8765f43..9f4bbc9 100644
--- a/attn/attn_dbus.cpp
+++ b/attn/attn_dbus.cpp
@@ -63,15 +63,19 @@
         }
         else
         {
-            std::string traceMsg =
-                "dbusMethod service not found: " + i_path + ", " + i_interface;
-            trace<level::INFO>(traceMsg.c_str());
+            // This trace will be picked up in event log
+            trace<level::INFO>("dbusMethod service not found");
+            std::string traceMsgPath = std::string(i_path, maxTraceLen);
+            trace<level::INFO>(traceMsgPath.c_str());
+            std::string traceMsgIface = std::string(i_interface, maxTraceLen);
+            trace<level::INFO>(traceMsgIface.c_str());
         }
     }
     catch (const sdbusplus::exception::SdBusError& e)
     {
-        std::string traceMsg = "dbusMethod exception: " + std::string(e.what());
-        trace<level::INFO>(traceMsg.c_str());
+        trace<level::INFO>("dbusMethod exception");
+        std::string traceMsg = std::string(e.what(), maxTraceLen);
+        trace<level::ERROR>(traceMsg.c_str());
     }
 
     return rc;
@@ -114,9 +118,9 @@
         }
         catch (const sdbusplus::exception::SdBusError& e)
         {
-            std::string traceMsg =
-                "createPel exception: " + std::string(e.what());
-            trace<level::INFO>(traceMsg.c_str());
+            trace<level::INFO>("createPel exception");
+            std::string traceMsg = std::string(e.what(), maxTraceLen);
+            trace<level::ERROR>(traceMsg.c_str());
         }
     }
 
@@ -168,9 +172,9 @@
         }
         catch (const sdbusplus::exception::SdBusError& e)
         {
-            std::string traceMsg =
-                "createPelRaw exception: " + std::string(e.what());
-            trace<level::INFO>(traceMsg.c_str());
+            trace<level::INFO>("createPelRaw exception");
+            std::string traceMsg = std::string(e.what(), maxTraceLen);
+            trace<level::ERROR>(traceMsg.c_str());
         }
     }
 }
@@ -208,8 +212,9 @@
         }
         catch (const sdbusplus::exception::SdBusError& e)
         {
-            std::string traceMsg = "getPel exception: " + std::string(e.what());
-            trace<level::INFO>(traceMsg.c_str());
+            trace<level::INFO>("getPel exception");
+            std::string traceMsg = std::string(e.what(), maxTraceLen);
+            trace<level::ERROR>(traceMsg.c_str());
         }
     }