erkeyb/include/logging.h

Go to the documentation of this file.
00001 #ifndef __LOGGING_H__
00002 #define __LOGGING_H__
00003 
00004 #include <stdarg.h>
00005 #include <stdio.h>
00006 
00007 // Uncomment one of more of these defines to enable
00008 // the logging macros
00009 
00010 //#define DBG_ENABLE_LOGGING
00011 //#define DBG_ENABLE_ASSERTIONS
00012 //#define DBG_ENABLE_INSTRUMENTATION
00013 
00014 #if defined DBG_ENABLE_LOGGING
00015 
00016 #define DBG(format, args...) \
00017             fprintf(stdout, format, ##args)
00018 
00019 #define ERR(format, args...) \
00020             fprintf(stderr, format, ##args)
00021 
00022 #else 
00023 
00024 #define DBG(format, args...) 
00025 #define ERR(format, args...) 
00026 
00027 #endif 
00028 
00029 #if defined DBG_ENABLE_ASSERTIONS
00030 
00031 #define DBG_ASSERT( test ) \
00032             do { \
00033             if ( ! (test) ) \
00034             {   \
00035             fprintf(stderr, "DBG_ASSERT Condition: \"%s\" FAILED at %s: %s() at line %d\n ", __STRING(test),  __FILE__ , __func__, __LINE__ ); \
00036             } \
00037             } while (0) 
00038 
00039 #else 
00040 
00041 #define DBG_ASSERT( test ) 
00042 
00043 #endif 
00044 
00045 #if defined DBG_ENABLE_INSTRUMENTATION
00046 
00047 #define DBG_ENTRY \
00048         fprintf(stdout, "ENTRY: %s: %s(): at line %d\n", __FILE__, __func__, __LINE__ ) 
00049 
00050 #define DBG_EXIT \
00051         fprintf(stdout, "EXIT : %s: %s(): at line %d\n", __FILE__, __func__, __LINE__ ) 
00052 
00053 #else
00054 
00055 #define DBG_ENTRY 
00056 #define DBG_EXIT 
00057 
00058 #endif 
00059 
00060 
00061 #endif /* __LOGGING_H__ */
Generated by  doxygen 1.6.2-20100208