* [GAM-11] make project compilable without DLT
authorFrank Herchet <frank.fh.herchet@bmw.de>
Fri, 24 Feb 2012 12:29:02 +0000 (13:29 +0100)
committerFrank Herchet <frank.fh.herchet@bmw.de>
Fri, 24 Feb 2012 12:29:02 +0000 (13:29 +0100)
AudioManagerDaemon/src/DLTWrapper.cpp
includes/DLTWrapper.h

index 33a48e8..a5b51ac 100644 (file)
@@ -22,6 +22,7 @@
  *
  */
 
+
 #include "DLTWrapper.h"
 #include <cassert>
 
@@ -36,7 +37,9 @@ DLTWrapper *DLTWrapper::instance()
 
 void DLTWrapper::unregisterContext(DltContext & handle)
 {
+#ifdef WITH_DLT
     dlt_unregister_context(&handle);
+#endif
 }
 
 DLTWrapper::DLTWrapper() :
@@ -47,71 +50,98 @@ DLTWrapper::DLTWrapper() :
 
 void DLTWrapper::registerApp(const char *appid, const char *description)
 {
+#ifdef WITH_DLT
     dlt_register_app(appid, description);
     //register a default context
     dlt_register_context(&mDltContext, "def", "default Context registered by DLTWrapper CLass");
+#endif
 }
 
 void DLTWrapper::registerContext(DltContext& handle, const char *contextid, const char *description)
 {
+#ifdef WITH_DLT
     dlt_register_context(&handle, contextid, description);
+#endif
 }
 
 void DLTWrapper::init(DltLogLevelType loglevel, DltContext* context)
 {
     if (!context)
         context = &mDltContext;
+#ifdef WITH_DLT
     dlt_user_log_write_start(context, &mDltContextData, loglevel);
+#endif
+
 }
 
 void DLTWrapper::send()
 {
+#ifdef WITH_DLT
     dlt_user_log_write_finish(&mDltContextData);
+#endif
 }
 
 void DLTWrapper::append(const int8_t value)
 {
+#ifdef WITH_DLT
     dlt_user_log_write_int8(&mDltContextData, value);
+#endif
 }
 
 void DLTWrapper::append(const uint8_t value)
 {
+#ifdef WITH_DLT
     dlt_user_log_write_uint8(&mDltContextData, value);
+#endif
 }
 
 void DLTWrapper::append(const int16_t value)
 {
+#ifdef WITH_DLT
     dlt_user_log_write_int16(&mDltContextData, value);
+#endif
 }
 
 void DLTWrapper::append(const uint16_t value)
 {
+#ifdef WITH_DLT
     dlt_user_log_write_uint16(&mDltContextData, value);
+#endif
 }
 
 void DLTWrapper::append(const int32_t value)
 {
+#ifdef WITH_DLT
     dlt_user_log_write_int32(&mDltContextData, value);
+#endif
 }
 
 void DLTWrapper::append(const uint32_t value)
 {
+#ifdef WITH_DLT
     dlt_user_log_write_uint32(&mDltContextData, value);
+#endif
 }
 
 void DLTWrapper::append(const char*& value)
 {
+#ifdef WITH_DLT
     dlt_user_log_write_string(&mDltContextData, value);
+#endif
 }
 
 void DLTWrapper::append(const std::string& value)
 {
+#ifdef WITH_DLT
     dlt_user_log_write_string(&mDltContextData, value.c_str());
+#endif
 }
 
 void DLTWrapper::append(const bool value)
 {
+#ifdef WITH_DLT
     dlt_user_log_write_bool(&mDltContextData, static_cast<uint8_t>(value));
+#endif
 }
 
 DLTWrapper::~DLTWrapper()
index dcce4ab..7d72836 100644 (file)
 #ifndef DLTWRAPPER_H_
 #define DLTWRAPPER_H_
 
+#include "config.h"
+
+#ifdef WITH_DLT
 #include <dlt/dlt.h>
+#else
+
+#include <stdint.h>
+
+#define DLT_USER_BUF_MAX_SIZE 2048
+
+/**
+ * This structure is used for every context used in an application.
+ */
+typedef struct
+{
+    char contextID[4];                            /**< context id */
+    int32_t log_level_pos;                        /**< offset in user-application context field */
+} DltContext;
+
+/**
+ * Definitions of DLT log level
+ */
+typedef enum
+{
+    DLT_LOG_DEFAULT =             -1,   /**< Default log level */
+    DLT_LOG_OFF     =           0x00,   /**< Log level off */
+    DLT_LOG_FATAL   =           0x01,   /**< fatal system error */
+    DLT_LOG_ERROR   =           0x02,   /**< error with impact to correct functionality */
+    DLT_LOG_WARN    =           0x03,   /**< warning, correct behaviour could not be ensured */
+    DLT_LOG_INFO    =           0x04,   /**< informational */
+    DLT_LOG_DEBUG   =           0x05,   /**< debug  */
+    DLT_LOG_VERBOSE =           0x06    /**< highest grade of information */
+} DltLogLevelType;
+
+/**
+ * This structure is used for context data used in an application.
+ */
+typedef struct
+{
+    DltContext *handle;                           /**< pointer to DltContext */
+    unsigned char buffer[DLT_USER_BUF_MAX_SIZE];  /**< buffer for building log message*/
+    int32_t size;                                 /**< payload size */
+    int32_t log_level;                            /**< log level */
+    int32_t trace_status;                         /**< trace status */
+    int32_t args_num;                             /**< number of arguments for extended header*/
+    uint8_t mcnt;                                 /**< message counter */
+    char* context_description;                    /**< description of context */
+} DltContextData;
+
+#define DLT_DECLARE_CONTEXT(CONTEXT) \
+DltContext CONTEXT;
+
+
+#define DLT_IMPORT_CONTEXT(CONTEXT) \
+extern DltContext CONTEXT;
+
+#endif
+
 #include <string>
 
 class DLTWrapper