diff options
author | Sathishkumar | 2013-09-05 01:42:28 -0500 |
---|---|---|
committer | Saurabh Bipin Chandra | 2013-09-05 11:09:17 -0500 |
commit | 2a9f015d989f41520dfdaa424bf6f598fa6a7c3c (patch) | |
tree | 3337a1676d8929e9f377b14fe3795900eee65d14 | |
parent | e08aec49c5bee1a70ea4b8a6e1d29a5d09c8ec2e (diff) | |
download | libdce2-2a9f015d989f41520dfdaa424bf6f598fa6a7c3c.tar.gz libdce2-2a9f015d989f41520dfdaa424bf6f598fa6a7c3c.tar.xz libdce2-2a9f015d989f41520dfdaa424bf6f598fa6a7c3c.zip |
[TRACE] Debug Log levels enabled
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>
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | dce_priv.h | 38 | ||||
-rw-r--r-- | libdce.c | 2 |
3 files changed, 26 insertions, 17 deletions
diff --git a/Makefile.am b/Makefile.am index 356c4cb..f10122f 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -16,7 +16,8 @@ CE_CFLAGS = \ | |||
16 | -I$(top_srcdir)/packages/xdais \ | 16 | -I$(top_srcdir)/packages/xdais \ |
17 | -I$(top_srcdir)/packages/xdctools \ | 17 | -I$(top_srcdir)/packages/xdctools \ |
18 | -I$(IPC_HEADERS)/ \ | 18 | -I$(IPC_HEADERS)/ \ |
19 | -DBUILDOS_LINUX=1 \ | 19 | -DBUILDOS_LINUX=1 -DDCE_DEBUG_LEVEL=1 \ |
20 | -DDCE_DEBUG_ENABLE=1 \ | ||
20 | -Wno-pointer-to-int-cast | 21 | -Wno-pointer-to-int-cast |
21 | 22 | ||
22 | 23 | ||
@@ -33,28 +33,36 @@ | |||
33 | #ifndef __DCE_PRIV_H__ | 33 | #ifndef __DCE_PRIV_H__ |
34 | #define __DCE_PRIV_H__ | 34 | #define __DCE_PRIV_H__ |
35 | 35 | ||
36 | 36 | extern int dce_debug; | |
37 | #ifdef BUILDOS_QNX | ||
38 | #include <sys/slog.h> | ||
39 | |||
40 | 37 | ||
41 | /********************* MACROS ************************/ | 38 | /********************* MACROS ************************/ |
42 | /***************** TRACE MACROS *********************/ | 39 | /***************** TRACE MACROS *********************/ |
43 | /* Need to make it OS specific and support different trace levels */ | 40 | /* Need to make it OS specific and support different trace levels */ |
44 | #define ERROR(FMT, ...) do { \ | 41 | |
42 | /* set desired trace level: | ||
43 | * 1 - error | ||
44 | * 2 - error, debug | ||
45 | * 3 - error, debug, info (very verbose) | ||
46 | */ | ||
47 | #ifdef DCE_DEBUG_ENABLE | ||
48 | #define ERROR(FMT,...) TRACE(1, "ERROR: " FMT, ##__VA_ARGS__) | ||
49 | #define DEBUG(FMT,...) TRACE(2, "DEBUG: " FMT, ##__VA_ARGS__) | ||
50 | #define INFO(FMT,...) TRACE(3, "INFO: " FMT, ##__VA_ARGS__) | ||
51 | #else | ||
52 | #define ERROR(FMT,...) | ||
53 | #define DEBUG(FMT,...) | ||
54 | #define INFO(FMT,...) | ||
55 | #endif | ||
56 | |||
57 | #ifdef BUILDOS_QNX | ||
58 | #include <sys/slog.h> | ||
59 | #define TRACE(lvl,FMT, ...) do if ((lvl) <= dce_debug) { \ | ||
45 | slogf(42, _SLOG_INFO, "%s:%d:\t%s\terror: " FMT, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \ | 60 | slogf(42, _SLOG_INFO, "%s:%d:\t%s\terror: " FMT, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \ |
46 | } while( 0 ) | 61 | } while( 0 ) |
47 | #define DEBUG(FMT, ...) do { \ | ||
48 | slogf(42, _SLOG_DEBUG2, "%s:%d:\t%s\tdebug: " FMT, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \ | ||
49 | } while( 0 ) | ||
50 | #endif | ||
51 | 62 | ||
52 | #ifdef BUILDOS_LINUX | 63 | #elif defined BUILDOS_LINUX |
53 | #define ERROR(FMT, ...) do { \ | 64 | #define TRACE(lvl,FMT, ...) do if ((lvl) <= dce_debug) { \ |
54 | printf("%s:%d:\t%s\t Error: "FMT,__FILE__, __LINE__,__FUNCTION__ ,##__VA_ARGS__); \ | 65 | printf("%s:%d:\t%s\t Error: "FMT,__FILE__, __LINE__,__FUNCTION__ ,##__VA_ARGS__); \ |
55 | }while( 0 ) | ||
56 | #define DEBUG(FMT, ...) do { \ | ||
57 | printf("%s:%d:\t%s\t Debug: "FMT,__FILE__, __LINE__,__FUNCTION__ ,##__VA_ARGS__); \ | ||
58 | }while( 0 ) | 66 | }while( 0 ) |
59 | #endif | 67 | #endif |
60 | 68 | ||
@@ -86,7 +86,7 @@ | |||
86 | MmRpc_Handle MmRpcHandle = NULL; | 86 | MmRpc_Handle MmRpcHandle = NULL; |
87 | sem_t *dce_semaphore = NULL; | 87 | sem_t *dce_semaphore = NULL; |
88 | static int count = 0; | 88 | static int count = 0; |
89 | 89 | int dce_debug = DCE_DEBUG_LEVEL; | |
90 | 90 | ||
91 | /****************** INLINE FUNCTIONS ********************/ | 91 | /****************** INLINE FUNCTIONS ********************/ |
92 | 92 | ||