From: Frank Herchet Date: Wed, 29 Feb 2012 14:42:08 +0000 (+0100) Subject: * fix debug output to stdout if WITH_DLT undefined X-Git-Tag: 1.0~17^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=792540e42b356074b968149284985c3686b75139;p=profile%2Fivi%2Fgenivi%2Fgenivi-audio-manager.git * fix debug output to stdout if WITH_DLT undefined --- diff --git a/AudioManagerDaemon/src/DLTWrapper.cpp b/AudioManagerDaemon/src/DLTWrapper.cpp index ad03692..cd03fcc 100644 --- a/AudioManagerDaemon/src/DLTWrapper.cpp +++ b/AudioManagerDaemon/src/DLTWrapper.cpp @@ -101,9 +101,10 @@ void DLTWrapper::send() dlt_user_log_write_finish(&mDltContextData); #else if(mEnableNoDLTDebug) - std::cout << "[" << mDltContext.contextID << "] " << std::string(mDltContextData.buffer) << std::endl; + std::cout << "[" << mDltContext.contextID << "] " << mDltContextData.buffer.str().c_str() << std::endl; - mDltContextData.size = 0; + mDltContextData.buffer.str(""); + mDltContextData.buffer.clear(); #endif } @@ -161,13 +162,12 @@ void DLTWrapper::append(const uint32_t value) #endif } -void DLTWrapper::append(const char*& value) +void DLTWrapper::append(const char* &value) { #ifdef WITH_DLT dlt_user_log_write_string(&mDltContextData, value); #else - memcpy((mDltContextData.buffer+mDltContextData.size),value,strlen(value)); - mDltContextData.size += strlen(value); + mDltContextData.buffer << value; #endif } @@ -176,8 +176,7 @@ void DLTWrapper::append(const std::string& value) #ifdef WITH_DLT dlt_user_log_write_string(&mDltContextData, value.c_str()); #else - memcpy((mDltContextData.buffer+mDltContextData.size),value.c_str(),value.size()); - mDltContextData.size += value.size(); + mDltContextData.buffer << value; #endif } @@ -193,11 +192,7 @@ void DLTWrapper::append(const bool value) #ifndef WITH_DLT template void DLTWrapper::appendNoDLT(T value) { - if((mDltContextData.size + sizeof(value)) < DLT_USER_BUF_MAX_SIZE) - { - memcpy((mDltContextData.buffer+mDltContextData.size),&(value),sizeof(value)); - mDltContextData.size += sizeof(value); - } + mDltContextData.buffer << value; } void DLTWrapper::enableNoDLTDebug(const bool enableNoDLTDebug) diff --git a/includes/DLTWrapper.h b/includes/DLTWrapper.h index 3a9482a..a133f38 100644 --- a/includes/DLTWrapper.h +++ b/includes/DLTWrapper.h @@ -32,6 +32,7 @@ #else #include +#include #define DLT_USER_BUF_MAX_SIZE 2048 @@ -65,8 +66,7 @@ typedef enum typedef struct { DltContext *handle; /**< pointer to DltContext */ - char buffer[DLT_USER_BUF_MAX_SIZE]; /**< buffer for building log message*/ - int32_t size; /**< payload size */ + std::stringstream buffer; /**< buffer for building log message*/ int32_t log_level; /**< log level */ int32_t trace_status; /**< trace status */ int32_t args_num; /**< number of arguments for extended header*/ @@ -81,7 +81,7 @@ DltContext CONTEXT; #define DLT_IMPORT_CONTEXT(CONTEXT) \ extern DltContext CONTEXT; -#endif +#endif // WITH_DLT #include