summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Lorenz <jlorenz@de.adit-jv.com>2014-11-12 08:40:47 (GMT)
committerChristian Linke <christian.linke@bmw.de>2015-02-17 13:18:35 (GMT)
commita4539202bc7bab8c17d4c532ccb4cee1c4daed09 (patch)
treee4472254c6a874fdb07e31c9699ea6a1bc524069
parent6e700bfc7faecb6d7e0f31c9d08b8b4f6cd1b3dd (diff)
downloadaudiomanager-a4539202bc7bab8c17d4c532ccb4cee1c4daed09.tar.gz
Bug #298 - DLT messages will be created only in case respective log level is activatedIntreprid_stable_branch
Signed-off-by: Jens Lorenz <jlorenz@de.adit-jv.com>
-rw-r--r--AudioManagerDaemon/src/CAmDltWrapper.cpp11
-rw-r--r--include/shared/CAmDltWrapper.h96
2 files changed, 72 insertions, 35 deletions
diff --git a/AudioManagerDaemon/src/CAmDltWrapper.cpp b/AudioManagerDaemon/src/CAmDltWrapper.cpp
index d1bbab2..fc2aaa4 100644
--- a/AudioManagerDaemon/src/CAmDltWrapper.cpp
+++ b/AudioManagerDaemon/src/CAmDltWrapper.cpp
@@ -13,6 +13,7 @@
*
*
* \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ * Jens Lorenz, jlorenz@de.adit-jv.com ADIT 2014
*
* \file CAmDltWrapper.cpp
* For further information see http://www.genivi.org/.
@@ -108,19 +109,23 @@ void CAmDltWrapper::registerContext(DltContext& handle, const char *contextid, c
#endif
}
-void CAmDltWrapper::init(DltLogLevelType loglevel, DltContext* context)
+bool CAmDltWrapper::init(DltLogLevelType loglevel, DltContext* context)
{
(void) loglevel;
pthread_mutex_lock(&mMutex);
if (!context)
context = &mDltContext;
#ifdef WITH_DLT
- dlt_user_log_write_start(context, &mDltContextData, loglevel);
+ if (dlt_user_log_write_start(context, &mDltContextData, loglevel) <= 0)
+ {
+ pthread_mutex_unlock(&mMutex);
+ return false;
+ }
#else
if(mEnableNoDLTDebug)
std::cout << "\e[0;34m[" << context->contextID << "]\e[0;30m\t";
#endif
-
+ return true;
}
void CAmDltWrapper::send()
diff --git a/include/shared/CAmDltWrapper.h b/include/shared/CAmDltWrapper.h
index 177fd98..cc52faf 100644
--- a/include/shared/CAmDltWrapper.h
+++ b/include/shared/CAmDltWrapper.h
@@ -2,6 +2,7 @@
* Copyright (C) 2012, BMW AG
*
* \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ * Jens Lorenz, jlorenz@de.adit-jv.com ADIT 2014
*
* \copyright
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
@@ -95,7 +96,7 @@ public:
void registerContext(DltContext& handle, const char *contextid, const char * description);
void unregisterContext(DltContext& handle);
- void init(DltLogLevelType loglevel, DltContext* context = NULL);
+ bool init(DltLogLevelType loglevel, DltContext* context = NULL);
void deinit();
void send();
void append(const int8_t value);
@@ -143,7 +144,8 @@ inline CAmDltWrapper* getWrapper()
template<typename T> void logInfo(T value)
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_INFO);
+ if (!inst->init(DLT_LOG_INFO))
+ return;
inst->append(value);
inst->send();
}
@@ -157,7 +159,8 @@ template<typename T, typename T1> void logInfo(T value, T1 value1)
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_INFO);
+ if (!inst->init(DLT_LOG_INFO))
+ return;
inst->append(value);
inst->append(value1);
inst->send();
@@ -174,7 +177,8 @@ template<typename T, typename T1, typename T2> void logInfo(T value, T1 value1,
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_INFO);
+ if (!inst->init(DLT_LOG_INFO))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -193,7 +197,8 @@ template<typename T, typename T1, typename T2, typename T3> void logInfo(T value
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_INFO);
+ if (!inst->init(DLT_LOG_INFO))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -214,7 +219,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4> void lo
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_INFO);
+ if (!inst->init(DLT_LOG_INFO))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -237,7 +243,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_INFO);
+ if (!inst->init(DLT_LOG_INFO))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -262,7 +269,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_INFO);
+ if (!inst->init(DLT_LOG_INFO))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -289,7 +297,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_INFO);
+ if (!inst->init(DLT_LOG_INFO))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -318,7 +327,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_INFO);
+ if (!inst->init(DLT_LOG_INFO))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -349,7 +359,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_INFO);
+ if (!inst->init(DLT_LOG_INFO))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -382,7 +393,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_INFO);
+ if (!inst->init(DLT_LOG_INFO))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -406,7 +418,8 @@ template<typename T> void logError(T value)
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_ERROR);
+ if (!inst->init(DLT_LOG_ERROR))
+ return;
inst->append(value);
inst->send();
@@ -421,7 +434,8 @@ template<typename T, typename T1> void logError(T value, T1 value1)
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_ERROR);
+ if (!inst->init(DLT_LOG_ERROR))
+ return;
inst->append(value);
inst->append(value1);
inst->send();
@@ -438,7 +452,8 @@ template<typename T, typename T1, typename T2> void logError(T value, T1 value1,
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_ERROR);
+ if (!inst->init(DLT_LOG_ERROR))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -457,7 +472,8 @@ template<typename T, typename T1, typename T2, typename T3> void logError(T valu
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_ERROR);
+ if (!inst->init(DLT_LOG_ERROR))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -478,7 +494,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4> void lo
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_ERROR);
+ if (!inst->init(DLT_LOG_ERROR))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -501,7 +518,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_ERROR);
+ if (!inst->init(DLT_LOG_ERROR))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -526,7 +544,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_ERROR);
+ if (!inst->init(DLT_LOG_ERROR))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -553,7 +572,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_ERROR);
+ if (!inst->init(DLT_LOG_ERROR))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -582,7 +602,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_ERROR);
+ if (!inst->init(DLT_LOG_ERROR))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -613,7 +634,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_ERROR);
+ if (!inst->init(DLT_LOG_ERROR))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -646,7 +668,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(DLT_LOG_ERROR);
+ if (!inst->init(DLT_LOG_ERROR))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -672,7 +695,8 @@ template<typename T> void log(DltContext* const context, DltLogLevelType logleve
{
CAmDltWrapper* inst(getWrapper());
- inst->init(loglevel, context);
+ if (!inst->init(loglevel, context))
+ return;
inst->append(value);
inst->send();
@@ -689,7 +713,8 @@ template<typename T, typename T1> void log(DltContext* const context, DltLogLeve
{
CAmDltWrapper* inst(getWrapper());
- inst->init(loglevel, context);
+ if (!inst->init(loglevel, context))
+ return;
inst->append(value);
inst->append(value1);
inst->send();
@@ -708,7 +733,8 @@ template<typename T, typename T1, typename T2> void log(DltContext* const contex
{
CAmDltWrapper* inst(getWrapper());
- inst->init(loglevel, context);
+ if (!inst->init(loglevel, context))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -729,7 +755,8 @@ template<typename T, typename T1, typename T2, typename T3> void log(DltContext*
{
CAmDltWrapper* inst(getWrapper());
- inst->init(loglevel, context);
+ if (!inst->init(loglevel, context))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -752,7 +779,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4> void lo
{
CAmDltWrapper* inst(getWrapper());
- inst->init(loglevel, context);
+ if (!inst->init(loglevel, context))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -777,7 +805,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(loglevel, context);
+ if (!inst->init(loglevel, context))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -804,7 +833,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(loglevel, context);
+ if (!inst->init(loglevel, context))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -833,7 +863,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(loglevel, context);
+ if (!inst->init(loglevel, context))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);
@@ -864,7 +895,8 @@ template<typename T, typename T1, typename T2, typename T3, typename T4, typenam
{
CAmDltWrapper* inst(getWrapper());
- inst->init(loglevel, context);
+ if (!inst->init(loglevel, context))
+ return;
inst->append(value);
inst->append(value1);
inst->append(value2);