diff options
author | Jens Lorenz <jlorenz@de.adit-jv.com> | 2015-09-10 14:48:34 +0200 |
---|---|---|
committer | Christian Linke <christian.linke@bmw.de> | 2015-09-16 08:14:01 +0100 |
commit | 3315426039419a1ad5b5c80f5481080cc77a8a16 (patch) | |
tree | 560b1f641d87667f8ba3db8e2f404ff443e1bc83 /AudioManagerUtilities/src | |
parent | 1423d7d9f4f0f67c3c354f8a334a1485734b7f24 (diff) | |
download | audiomanager-3315426039419a1ad5b5c80f5481080cc77a8a16.tar.gz |
Utility: DLT: New registerContext allows to set log level and trace status from application
Signed-off-by: Jens Lorenz <jlorenz@de.adit-jv.com>
Diffstat (limited to 'AudioManagerUtilities/src')
-rw-r--r-- | AudioManagerUtilities/src/CAmDltWrapper.cpp | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/AudioManagerUtilities/src/CAmDltWrapper.cpp b/AudioManagerUtilities/src/CAmDltWrapper.cpp index 6a6d8dd..149edcd 100644 --- a/AudioManagerUtilities/src/CAmDltWrapper.cpp +++ b/AudioManagerUtilities/src/CAmDltWrapper.cpp @@ -104,8 +104,35 @@ void CAmDltWrapper::registerContext(DltContext& handle, const char *contextid, c mDltContextData.context_description = new char[str_len + 1]; (void) strcpy(mDltContextData.context_description,description); } + mDltContext.log_level_user = DLT_DEFAULT_LOG_LEVEL; } + handle.log_level_user = DLT_DEFAULT_LOG_LEVEL; + std::cout << "\e[0;34m[DLT]\e[0;30m\tRegistering Context " << contextid << " , " << description << std::endl; + +#endif +} +void CAmDltWrapper::registerContext(DltContext& handle, const char *contextid, const char * description, + const DltLogLevelType level, const DltTraceStatusType status) +{ +#ifdef WITH_DLT + dlt_register_context_ll_ts(&handle, contextid, description, level, status); +#else + strncpy(handle.contextID,contextid,4); + + // store only the first contextID + if(0 == strlen(mDltContext.contextID)) + { + memcpy(&mDltContext.contextID,contextid,4); + const size_t str_len = strlen(description); + if(str_len < 2000) + { + mDltContextData.context_description = new char[str_len + 1]; + (void) strcpy(mDltContextData.context_description,description); + } + mDltContext.log_level_user = level; + } + handle.log_level_user = level; std::cout << "\e[0;34m[DLT]\e[0;30m\tRegistering Context " << contextid << " , " << description << std::endl; #endif @@ -119,13 +146,15 @@ bool CAmDltWrapper::init(DltLogLevelType loglevel, DltContext* context) context = &mDltContext; #ifdef WITH_DLT if (dlt_user_log_write_start(context, &mDltContextData, loglevel) <= 0) +#else + if((mEnableNoDLTDebug == false) || (loglevel > context->log_level_user)) +#endif { - pthread_mutex_unlock(&mMutex); - return false; + pthread_mutex_unlock(&mMutex); + return false; } -#else - if(mEnableNoDLTDebug) - std::cout << "\e[0;34m[" << context->contextID << "]\e[0;30m\t"; +#ifndef WITH_DLT + std::cout << "\e[0;34m[" << context->contextID << "]\e[0;30m\t"; #endif return true; } |