summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Herchet <frank.fh.herchet@bmw.de>2012-02-29 15:42:08 +0100
committerFrank Herchet <frank.fh.herchet@bmw.de>2012-02-29 15:42:08 +0100
commit792540e42b356074b968149284985c3686b75139 (patch)
tree98d00c4f2352d8333ff49d46d18e793929955c86
parent2d5384afc024850758449c884844654c915efa1b (diff)
downloadaudiomanager-792540e42b356074b968149284985c3686b75139.tar.gz
* fix debug output to stdout if WITH_DLT undefined
-rw-r--r--AudioManagerDaemon/src/DLTWrapper.cpp19
-rw-r--r--includes/DLTWrapper.h6
2 files changed, 10 insertions, 15 deletions
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<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)
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 <stdint.h>
+#include <sstream>
#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 <string>