handle am_error in dltwrapper
[profile/ivi/genivi/genivi-audio-manager.git] / AudioManagerDaemon / src / CAmDltWrapper.cpp
index aa7e423..158a7d6 100644 (file)
@@ -52,6 +52,13 @@ void CAmDltWrapper::unregisterContext(DltContext & handle)
 #endif
 }
 
+void CAmDltWrapper::deinit()
+{
+#ifdef WITH_DLT
+    unregisterContext(mDltContext);
+#endif
+}
+
 CAmDltWrapper::CAmDltWrapper(const bool enableNoDLTDebug) :
 #ifndef WITH_DLT
         mEnableNoDLTDebug(enableNoDLTDebug),
@@ -61,7 +68,7 @@ CAmDltWrapper::CAmDltWrapper(const bool enableNoDLTDebug) :
 {
     (void) enableNoDLTDebug;
 #ifndef WITH_DLT
-    std::cout << "[DLT] Running without DLT-support" << std::endl;
+    std::cout << "\e[0;34m[DLT]\e[0;30m\tRunning without DLT-support" << std::endl;
 #endif
 }
 
@@ -82,7 +89,7 @@ void CAmDltWrapper::registerContext(DltContext& handle, const char *contextid, c
 #ifdef WITH_DLT
     dlt_register_context(&handle, contextid, description);
 #else
-    (void) handle;
+    strncpy(handle.contextID,contextid,4);
 
     // store only the first contextID
     if(0 == strlen(mDltContext.contextID))
@@ -96,6 +103,8 @@ void CAmDltWrapper::registerContext(DltContext& handle, const char *contextid, c
         }
     }
 
+    std::cout << "\e[0;34m[DLT]\e[0;30m\tRegistering Context " << contextid << " , " << description << std::endl;
+
 #endif
 }
 
@@ -107,6 +116,9 @@ void CAmDltWrapper::init(DltLogLevelType loglevel, DltContext* context)
         context = &mDltContext;
 #ifdef WITH_DLT
     dlt_user_log_write_start(context, &mDltContextData, loglevel);
+#else
+    if(mEnableNoDLTDebug)
+        std::cout << "\e[0;34m[" << context->contextID << "]\e[0;30m\t";
 #endif
 
 }
@@ -117,7 +129,7 @@ void CAmDltWrapper::send()
     dlt_user_log_write_finish(&mDltContextData);
 #else
     if(mEnableNoDLTDebug)
-        std::cout << "[" << mDltContext.contextID << "] " << mDltContextData.buffer.str().c_str() << std::endl;
+        std::cout << mDltContextData.buffer.str().c_str() << std::endl;
 
     mDltContextData.buffer.str("");
     mDltContextData.buffer.clear();
@@ -224,6 +236,53 @@ void CAmDltWrapper::append(const uint64_t value)
 #endif
 }
 
+void CAmDltWrapper::append(am_Error_e value)
+{
+       std::string txt;
+       switch (value)
+       {
+               case am_Error_e::E_OK:
+                       txt="E_OK";
+                       break;
+               case am_Error_e::E_ABORTED:
+                       txt="E_ABORTED";
+                       break;
+               case am_Error_e::E_ALREADY_EXISTS:
+                       txt="E_ALREADY_EXISTS";
+                       break;
+               case am_Error_e::E_DATABASE_ERROR:
+                       txt="E_DATABASE_ERROR";
+                       break;
+               case am_Error_e::E_NON_EXISTENT:
+                       txt="E_NON_EXISTENT";
+                       break;
+               case am_Error_e::E_NOT_POSSIBLE:
+                       txt="E_NOT_POSSIBLE";
+                       break;
+               case am_Error_e::E_NOT_USED:
+                       txt="E_NOT_USED";
+                       break;
+               case am_Error_e::E_NO_CHANGE:
+                       txt="E_NO_CHANGE";
+                       break;
+               case am_Error_e::E_OUT_OF_RANGE:
+                       txt="E_OUT_OF_RANGE";
+                       break;
+               case am_Error_e::E_UNKNOWN:
+                       txt="E_UNKNOWN";
+                       break;
+               default:
+                       txt="E_UNKNOWN";
+
+       }
+#ifdef WITH_DLT
+
+    dlt_user_log_write_string(&mDltContextData, txt.c_str());
+#else
+    mDltContextData.buffer << txt;
+#endif
+}
+
 #ifndef WITH_DLT
 template<class T> void CAmDltWrapper::appendNoDLT(T value)
 {
@@ -239,7 +298,11 @@ void CAmDltWrapper::enableNoDLTDebug(const bool enableNoDLTDebug)
 CAmDltWrapper::~CAmDltWrapper()
 {
     if (mpDLTWrapper)
+    {
+        mpDLTWrapper->unregisterContext(mDltContext);
         delete mpDLTWrapper;
+    }
 }
 }
 
+