summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--AudioManagerDaemon/src/CAmDltWrapper.cpp17
-rw-r--r--AudioManagerDaemon/src/main.cpp24
-rw-r--r--include/shared/CAmDltWrapper.h8
4 files changed, 29 insertions, 21 deletions
diff --git a/.gitignore b/.gitignore
index fed9435..aa12f3d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ build/
doc/
packages/
.*
+/packages
diff --git a/AudioManagerDaemon/src/CAmDltWrapper.cpp b/AudioManagerDaemon/src/CAmDltWrapper.cpp
index 968f911..fc7e064 100644
--- a/AudioManagerDaemon/src/CAmDltWrapper.cpp
+++ b/AudioManagerDaemon/src/CAmDltWrapper.cpp
@@ -105,9 +105,10 @@ void CAmDltWrapper::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
}
@@ -170,8 +171,7 @@ void CAmDltWrapper::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
}
@@ -180,8 +180,7 @@ void CAmDltWrapper::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
}
@@ -197,11 +196,7 @@ void CAmDltWrapper::append(const bool value)
#ifndef WITH_DLT
template<class T> void CAmDltWrapper::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 CAmDltWrapper::enableNoDLTDebug(const bool enableNoDLTDebug)
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp
index b6acf5d..4e95baa 100644
--- a/AudioManagerDaemon/src/main.cpp
+++ b/AudioManagerDaemon/src/main.cpp
@@ -72,6 +72,9 @@ const char* USAGE_DESCRIPTION = "Usage:\tAudioManagerDaemon [options]\n"
"\t-h: print this message\t\n"
"\t-i: info about current settings \t\n"
"\t-v: print version\t\n"
+#ifndef WITH_DLT
+ "\t-V: print DLT logs to stdout\t\n"
+#endif
"\t-d: daemonize AudioManager \t\n"
"\t-p<path> path for sqlite database (default is in memory)\t\n"
"\t-t<port> port for telnetconnection\t\n"
@@ -89,6 +92,7 @@ std::string databasePath = std::string(":memory:");
unsigned int telnetport = DEFAULT_TELNETPORT;
unsigned int maxConnections = MAX_TELNETCONNECTIONS;
int fd0, fd1, fd2;
+bool enableNoDLTDebug = false;
void OutOfMemoryHandler()
{
@@ -149,7 +153,11 @@ void parseCommandLine(int argc, char **argv)
{
while (optind < argc)
{
+#ifdef WITH_DLT
int option = getopt(argc, argv, "h::v::c::l::r::L::R::d::t::m::i::p::");
+#else
+ int option = getopt(argc, argv, "h::v::V::c::l::r::L::R::d::t::m::i::p::");
+#endif
switch (option)
{
@@ -202,6 +210,12 @@ void parseCommandLine(int argc, char **argv)
printf("AudioManagerDaemon Version: %s\n", DAEMONVERSION);
exit(-1);
break;
+#ifndef WITH_DLT
+ case 'V':
+ printf("[DLT] debug output to stdout enabled\n");
+ enableNoDLTDebug = true;
+ break;
+#endif
case 'h':
default:
printf("AudioManagerDaemon Version: %s\n", DAEMONVERSION);
@@ -224,17 +238,17 @@ static void signalHandler(int sig, siginfo_t *siginfo, void *context)
int main(int argc, char *argv[])
{
- CAmDltWrapper::instance(true)->registerApp("AudioManagerDeamon", "AudioManagerDeamon");
- CAmDltWrapper::instance()->registerContext(AudioManager, "Main", "Main Context");
- logInfo("The Audiomanager is started");
- logInfo("The version of the Audiomanager", DAEMONVERSION);
-
listCommandPluginDirs.push_back(std::string(DEFAULT_PLUGIN_COMMAND_DIR));
listRoutingPluginDirs.push_back(std::string(DEFAULT_PLUGIN_ROUTING_DIR));
//parse the commandline options
parseCommandLine(argc, (char**) argv);
+ CAmDltWrapper::instance(true)->registerApp("AudioManagerDeamon", "AudioManagerDeamon");
+ CAmDltWrapper::instance()->registerContext(AudioManager, "Main", "Main Context");
+ logInfo("The Audiomanager is started");
+ logInfo("The version of the Audiomanager", DAEMONVERSION);
+
//now the signal handler:
struct sigaction signalAction;
memset(&signalAction, '\0', sizeof(signalAction));
diff --git a/include/shared/CAmDltWrapper.h b/include/shared/CAmDltWrapper.h
index ea6f246..0df9cde 100644
--- a/include/shared/CAmDltWrapper.h
+++ b/include/shared/CAmDltWrapper.h
@@ -24,6 +24,7 @@
#else
#include <stdint.h>
+#include <sstream>
namespace am {
@@ -59,8 +60,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*/
@@ -75,9 +75,7 @@ DltContext CONTEXT;
#define DLT_IMPORT_CONTEXT(CONTEXT) \
extern DltContext CONTEXT;
-}
-
-#endif
+#endif // WITH_DLT
#include <string>