(Logging) Ensure we do not output unrequired spaces & colons when trace is not enabled 70/46470/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 20 Aug 2015 16:23:19 +0000 (17:23 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 20 Aug 2015 16:23:28 +0000 (17:23 +0100)
Before: No Trace:
INFO: DALI: : MyDebug

Now: No Trace:
INFO: DALI: MyDebug

Before: Trace:
INFO: DALI: Entr: MyFunction()
INFO: DALI: :  MyDebug
INFO: DALI: Exit: MyFunction()

Now: Trace:
INFO: DALI: Entr: MyFunction()
INFO: DALI:     :  MyDebug
INFO: DALI: Exit: MyFunction()

Change-Id: I3a04b50154a4f23ca90cad5a7ad2ef26ae6cb1cf

dali/integration-api/debug.cpp

index dd62a17..e67b165 100644 (file)
@@ -198,13 +198,21 @@ void Filter::Log(LogLevel level, const char* format, ...)
     va_list arg;
     va_start(arg, format);
 
-    char *buffer = NULL;
-    int numChars = asprintf(&buffer, "%-*c %s", mNesting, ':', format);
-    if(numChars >= 0) // No error
+    if( mTraceEnabled )
     {
-      std::string message = ArgListToString(buffer, arg);
-      LogMessage(DebugInfo, message.c_str());
-      free(buffer);
+      char *buffer = NULL;
+      int numChars = asprintf( &buffer, "    %-*c %s", mNesting, ':', format );
+      if( numChars >= 0 ) // No error
+      {
+        std::string message = ArgListToString( buffer, arg );
+        LogMessage( DebugInfo, message.c_str() );
+        free( buffer );
+      }
+    }
+    else
+    {
+      std::string message = ArgListToString( format, arg );
+      LogMessage( DebugInfo, message.c_str() );
     }
     va_end(arg);
   }