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
}
#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
}
#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
}
#ifndef WITH_DLT
template<class T> 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)
#else
#include <stdint.h>
+#include <sstream>
#define DLT_USER_BUF_MAX_SIZE 2048
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*/
#define DLT_IMPORT_CONTEXT(CONTEXT) \
extern DltContext CONTEXT;
-#endif
+#endif // WITH_DLT
#include <string>