summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSathishkumar2013-09-05 01:42:28 -0500
committerSaurabh Bipin Chandra2013-09-05 11:09:17 -0500
commit2a9f015d989f41520dfdaa424bf6f598fa6a7c3c (patch)
tree3337a1676d8929e9f377b14fe3795900eee65d14 /dce_priv.h
parente08aec49c5bee1a70ea4b8a6e1d29a5d09c8ec2e (diff)
downloadhardware-ti-libdce-2a9f015d989f41520dfdaa424bf6f598fa6a7c3c.tar.gz
hardware-ti-libdce-2a9f015d989f41520dfdaa424bf6f598fa6a7c3c.tar.xz
hardware-ti-libdce-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>
Diffstat (limited to 'dce_priv.h')
-rw-r--r--dce_priv.h38
1 files changed, 23 insertions, 15 deletions
diff --git a/dce_priv.h b/dce_priv.h
index 7f2624f..70ee4c5 100644
--- a/dce_priv.h
+++ b/dce_priv.h
@@ -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 36extern 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