Gleb Klochkov / Mbed OS Climatcontroll_Main

Dependencies:   esp8266-driver

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