From a4539202bc7bab8c17d4c532ccb4cee1c4daed09 Mon Sep 17 00:00:00 2001 From: Jens Lorenz Date: Wed, 12 Nov 2014 09:40:47 +0100 Subject: Bug #298 - DLT messages will be created only in case respective log level is activated Signed-off-by: Jens Lorenz --- AudioManagerDaemon/src/CAmDltWrapper.cpp | 11 +++- include/shared/CAmDltWrapper.h | 96 +++++++++++++++++++++----------- 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 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 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 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 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 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 @@ templateinit(DLT_LOG_INFO); + if (!inst->init(DLT_LOG_INFO)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -262,7 +269,8 @@ templateinit(DLT_LOG_INFO); + if (!inst->init(DLT_LOG_INFO)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -289,7 +297,8 @@ templateinit(DLT_LOG_INFO); + if (!inst->init(DLT_LOG_INFO)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -318,7 +327,8 @@ templateinit(DLT_LOG_INFO); + if (!inst->init(DLT_LOG_INFO)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -349,7 +359,8 @@ templateinit(DLT_LOG_INFO); + if (!inst->init(DLT_LOG_INFO)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -382,7 +393,8 @@ templateinit(DLT_LOG_INFO); + if (!inst->init(DLT_LOG_INFO)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -406,7 +418,8 @@ template 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 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 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 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 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 @@ templateinit(DLT_LOG_ERROR); + if (!inst->init(DLT_LOG_ERROR)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -526,7 +544,8 @@ templateinit(DLT_LOG_ERROR); + if (!inst->init(DLT_LOG_ERROR)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -553,7 +572,8 @@ templateinit(DLT_LOG_ERROR); + if (!inst->init(DLT_LOG_ERROR)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -582,7 +602,8 @@ templateinit(DLT_LOG_ERROR); + if (!inst->init(DLT_LOG_ERROR)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -613,7 +634,8 @@ templateinit(DLT_LOG_ERROR); + if (!inst->init(DLT_LOG_ERROR)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -646,7 +668,8 @@ templateinit(DLT_LOG_ERROR); + if (!inst->init(DLT_LOG_ERROR)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -672,7 +695,8 @@ template 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 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 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 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 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 @@ templateinit(loglevel, context); + if (!inst->init(loglevel, context)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -804,7 +833,8 @@ templateinit(loglevel, context); + if (!inst->init(loglevel, context)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -833,7 +863,8 @@ templateinit(loglevel, context); + if (!inst->init(loglevel, context)) + return; inst->append(value); inst->append(value1); inst->append(value2); @@ -864,7 +895,8 @@ templateinit(loglevel, context); + if (!inst->init(loglevel, context)) + return; inst->append(value); inst->append(value1); inst->append(value2); -- cgit v1.2.1