From c9165568d85ad893a8656d658497f17797bd1351 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Thu, 20 Aug 2015 17:23:19 +0100 Subject: [PATCH] (Logging) Ensure we do not output unrequired spaces & colons when trace is not enabled 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 | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/dali/integration-api/debug.cpp b/dali/integration-api/debug.cpp index dd62a17..e67b165 100644 --- a/dali/integration-api/debug.cpp +++ b/dali/integration-api/debug.cpp @@ -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); } -- 2.7.4