Lee Kai Xuan / mbed-os

Fork of mbed-os by erkin yucel

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cfstore_debug.h Source File

cfstore_debug.h

Go to the documentation of this file.
00001 /** @file cfstore_debug.h
00002  *
00003  * component debug header file.
00004  */
00005 
00006 
00007 #ifndef __CFSTORE_DEBUG
00008 #define __CFSTORE_DEBUG
00009 
00010 #include <stdint.h>
00011 #include <assert.h>
00012 
00013 
00014 /* Debug Support */
00015 
00016 #define CFSTORE_LOG_NONE        0
00017 #define CFSTORE_LOG_ERR         1
00018 #define CFSTORE_LOG_WARN        2
00019 #define CFSTORE_LOG_NOTICE      3
00020 #define CFSTORE_LOG_INFO        4
00021 #define CFSTORE_LOG_DEBUG       5
00022 #define CFSTORE_LOG_FENTRY      6
00023 
00024 #define CFSTORE_LOG(_fmt, ...)                          \
00025   do                                                    \
00026   {                                                     \
00027         printf(_fmt, __VA_ARGS__);                      \
00028   }while(0);
00029 
00030 //todo: restore #define noCFSTORE_DEBUG
00031 #define noCFSTORE_DEBUG
00032 //#define CFSTORE_DEBUG
00033 #ifdef CFSTORE_DEBUG
00034 
00035 extern uint32_t cfstore_optDebug_g;
00036 extern uint32_t cfstore_optLogLevel_g;
00037 extern uint32_t cfstore_optLogTracepoint_g;
00038 
00039 
00040 /* uncomment for asserts to work */
00041 /* #undef NDEBUG */
00042 // todo: port to mbedOSV3++ #include <core-util/assert.h>
00043 
00044 #define CFSTORE_INLINE
00045 // todo: port to mbedOSV3++ #define CFSTORE_ASSERT  CORE_UTIL_ASSERT
00046 #define CFSTORE_ASSERT(...)
00047 
00048 #define CFSTORE_DBGLOG(_fmt, ...)                       \
00049   do                                                    \
00050   {                                                     \
00051     if(cfstore_optDebug_g && (cfstore_optLogLevel_g >= CFSTORE_LOG_DEBUG))  \
00052     {                                                   \
00053         printf(_fmt, __VA_ARGS__);                      \
00054     }                                                   \
00055   }while(0);
00056 
00057 
00058 #define CFSTORE_ERRLOG(_fmt, ...)                       \
00059   do                                                    \
00060   {                                                     \
00061     if(cfstore_optDebug_g && (cfstore_optLogLevel_g >= CFSTORE_LOG_ERR))  \
00062     {                                                   \
00063         printf(_fmt, __VA_ARGS__);                      \
00064     }                                                   \
00065   }while(0);
00066 
00067 
00068 #define CFSTORE_FENTRYLOG(_fmt, ...)                       \
00069   do                                                    \
00070   {                                                     \
00071     if(cfstore_optDebug_g && (cfstore_optLogLevel_g >= CFSTORE_LOG_FENTRY))  \
00072     {                                                   \
00073         printf(_fmt, __VA_ARGS__);                      \
00074     }                                                   \
00075   }while(0);
00076 
00077 
00078 /* tracepoints */
00079 #define CFSTORE_TP_NONE         0x0
00080 #define CFSTORE_TP_CLOSE        (1<<0)
00081 #define CFSTORE_TP_CREATE       (1<<1)
00082 #define CFSTORE_TP_DELETE       (1<<2)
00083 #define CFSTORE_TP_FILE         (1<<3)
00084 #define CFSTORE_TP_FIND         (1<<4)
00085 #define CFSTORE_TP_FLUSH        (1<<5)
00086 #define CFSTORE_TP_FSM          (1<<6)
00087 #define CFSTORE_TP_INIT         (1<<7)
00088 #define CFSTORE_TP_MEM          (1<<8)
00089 #define CFSTORE_TP_OPEN         (1<<9)
00090 #define CFSTORE_TP_READ         (1<<10)
00091 #define CFSTORE_TP_WRITE        (1<<11)
00092 #define CFSTORE_TP_VERBOSE1     (1<<12)
00093 #define CFSTORE_TP_VERBOSE2     (1<<13)
00094 #define CFSTORE_TP_VERBOSE3     (1<<14)
00095 #define CFSTORE_TP_CALLBACK     (1<<15)
00096 #define CFSTORE_TP_FENTRY       (1<<31)
00097 
00098 #define CFSTORE_TP(_tp, _fmt, ...)                                              \
00099 do                                                                              \
00100 {                                                                               \
00101     if(cfstore_optDebug_g && (cfstore_optLogLevel_g >= CFSTORE_LOG_DEBUG))      \
00102     {                                                                           \
00103         if((cfstore_optLogTracepoint_g & (_tp)) == (uint32_t)(_tp))             \
00104         {                                                                       \
00105             printf(_fmt, __VA_ARGS__);                                          \
00106         }                                                                       \
00107     }                                                                           \
00108 }while(0);
00109 
00110 
00111 #else
00112 #define CFSTORE_ASSERT(_x)                   do { } while(0)
00113 #define CFSTORE_INLINE                       inline
00114 #define CFSTORE_DBGLOG(_fmt, ...)            do { } while(0)
00115 #define CFSTORE_ERRLOG(_fmt, ...)            do { } while(0)
00116 #define CFSTORE_FENTRYLOG(_fmt, ...)         do { } while(0)
00117 #define CFSTORE_TP(_tp, _fmt, ...)           do { } while(0)
00118 #endif /* CFSTORE_DEBUG */
00119 
00120 
00121 #endif /*__CFSTORE_DEBUG*/