summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (from parent 1: e08aec4)
raw | patch | inline | side by side (from parent 1: e08aec4)
author | Sathishkumar <x0203598@ti.com> | |
Thu, 5 Sep 2013 06:42:28 +0000 (12:12 +0530) | ||
committer | Saurabh Bipin Chandra <a0131926@ti.com> | |
Thu, 5 Sep 2013 16:09:17 +0000 (21:39 +0530) |
This patch adds debug log levels to libdce.
To enable traces, set the DCE_DEBUG_ENABLE.
The trace level can be changed by setting
DCE_DEBUG_LEVEL= [1/2/3] during compile time.
Change-Id: I4bed53cc6e3af938c02221376662318e3a1b8ec4
Signed-off-by: Sathishkumar <x0203598@ti.com>
To enable traces, set the DCE_DEBUG_ENABLE.
The trace level can be changed by setting
DCE_DEBUG_LEVEL= [1/2/3] during compile time.
Change-Id: I4bed53cc6e3af938c02221376662318e3a1b8ec4
Signed-off-by: Sathishkumar <x0203598@ti.com>
Makefile.am | patch | blob | history | |
dce_priv.h | patch | blob | history | |
libdce.c | patch | blob | history |
diff --git a/Makefile.am b/Makefile.am
index 356c4cbb4ccb76d11c63eb57c1d6bfcd5b541423..f10122f21e772002019f388b50f0351816dc30fd 100644 (file)
--- a/Makefile.am
+++ b/Makefile.am
-I$(top_srcdir)/packages/xdais \
-I$(top_srcdir)/packages/xdctools \
-I$(IPC_HEADERS)/ \
-I$(top_srcdir)/packages/xdais \
-I$(top_srcdir)/packages/xdctools \
-I$(IPC_HEADERS)/ \
- -DBUILDOS_LINUX=1 \
+ -DBUILDOS_LINUX=1 -DDCE_DEBUG_LEVEL=1 \
+ -DDCE_DEBUG_ENABLE=1 \
-Wno-pointer-to-int-cast
-Wno-pointer-to-int-cast
diff --git a/dce_priv.h b/dce_priv.h
index 7f2624fbf7aa35fca73e7095db9c855149d2ee4b..70ee4c546e94a93d11bd27eadd32f189156b07eb 100644 (file)
--- a/dce_priv.h
+++ b/dce_priv.h
#ifndef __DCE_PRIV_H__
#define __DCE_PRIV_H__
#ifndef __DCE_PRIV_H__
#define __DCE_PRIV_H__
-
-#ifdef BUILDOS_QNX
-#include <sys/slog.h>
-
+extern int dce_debug;
/********************* MACROS ************************/
/***************** TRACE MACROS *********************/
/* Need to make it OS specific and support different trace levels */
/********************* MACROS ************************/
/***************** TRACE MACROS *********************/
/* Need to make it OS specific and support different trace levels */
-#define ERROR(FMT, ...) do { \
+
+/* set desired trace level:
+ * 1 - error
+ * 2 - error, debug
+ * 3 - error, debug, info (very verbose)
+ */
+#ifdef DCE_DEBUG_ENABLE
+#define ERROR(FMT,...) TRACE(1, "ERROR: " FMT, ##__VA_ARGS__)
+#define DEBUG(FMT,...) TRACE(2, "DEBUG: " FMT, ##__VA_ARGS__)
+#define INFO(FMT,...) TRACE(3, "INFO: " FMT, ##__VA_ARGS__)
+#else
+#define ERROR(FMT,...)
+#define DEBUG(FMT,...)
+#define INFO(FMT,...)
+#endif
+
+#ifdef BUILDOS_QNX
+#include <sys/slog.h>
+#define TRACE(lvl,FMT, ...) do if ((lvl) <= dce_debug) { \
slogf(42, _SLOG_INFO, "%s:%d:\t%s\terror: " FMT, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
} while( 0 )
slogf(42, _SLOG_INFO, "%s:%d:\t%s\terror: " FMT, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
} while( 0 )
-#define DEBUG(FMT, ...) do { \
- slogf(42, _SLOG_DEBUG2, "%s:%d:\t%s\tdebug: " FMT, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
-} while( 0 )
-#endif
-#ifdef BUILDOS_LINUX
-#define ERROR(FMT, ...) do { \
- printf("%s:%d:\t%s\t Error: "FMT,__FILE__, __LINE__,__FUNCTION__ ,##__VA_ARGS__); \
-}while( 0 )
-#define DEBUG(FMT, ...) do { \
- printf("%s:%d:\t%s\t Debug: "FMT,__FILE__, __LINE__,__FUNCTION__ ,##__VA_ARGS__); \
+#elif defined BUILDOS_LINUX
+#define TRACE(lvl,FMT, ...) do if ((lvl) <= dce_debug) { \
+ printf("%s:%d:\t%s\t Error: "FMT,__FILE__, __LINE__,__FUNCTION__ ,##__VA_ARGS__); \
}while( 0 )
#endif
}while( 0 )
#endif
diff --git a/libdce.c b/libdce.c
index 3bbed457fab91f3989d06755be5bd9e3128ab202..b781972c2b2b475a7bc310d85574f0ff9aa0564e 100644 (file)
--- a/libdce.c
+++ b/libdce.c
MmRpc_Handle MmRpcHandle = NULL;
sem_t *dce_semaphore = NULL;
static int count = 0;
MmRpc_Handle MmRpcHandle = NULL;
sem_t *dce_semaphore = NULL;
static int count = 0;
-
+int dce_debug = DCE_DEBUG_LEVEL;
/****************** INLINE FUNCTIONS ********************/
/****************** INLINE FUNCTIONS ********************/