sbgECom Library  4.0.1987-stable
C library to interface SBG Systems IMU/AHRS/INS
sbgDebug.h
Go to the documentation of this file.
1 
35 #ifndef SBG_DEBUG_H
36 #define SBG_DEBUG_H
37 
38 // sbgCommonLib headers
39 #include <sbgDefines.h>
40 
41 #ifndef SBG_DEBUG_LOG_CATEGORY
42  #define SBG_DEBUG_LOG_CATEGORY ("None")
43 #endif
44 
45 //----------------------------------------------------------------------//
46 //- Errors and warning definitions -//
47 //----------------------------------------------------------------------//
48 
52 typedef enum _SbgDebugLogType
53 {
59 
60 //----------------------------------------------------------------------//
61 //- Errors and warning macros -//
62 //----------------------------------------------------------------------//
63 
69 #define SBG_LOG_ERROR_CALL(errorCode, format, ...) sbgPlatformDebugLogMsg((const char*)__BASE_FILE__, (const char*)__func__, __LINE__, SBG_DEBUG_LOG_CATEGORY, SBG_DEBUG_LOG_TYPE_ERROR, errorCode, format, ##__VA_ARGS__)
70 
71 #if SBG_CONFIG_ENABLE_LOG_ERROR == 1
72  #define SBG_LOG_ERROR SBG_LOG_ERROR_CALL
73 #else
74  #define SBG_LOG_ERROR(format, ...) ((void)sizeof(SBG_LOG_ERROR_CALL(format, ## __VA_ARGS__), 0))
75 #endif
76 
82 #define SBG_LOG_WARNING_CALL(errorCode, format, ...) sbgPlatformDebugLogMsg((const char*)__BASE_FILE__, (const char*)__func__, __LINE__, SBG_DEBUG_LOG_CATEGORY, SBG_DEBUG_LOG_TYPE_WARNING, errorCode, format, ##__VA_ARGS__)
83 
84 #if SBG_CONFIG_ENABLE_LOG_WARNING == 1
85  #define SBG_LOG_WARNING SBG_LOG_WARNING_CALL
86 #else
87  #define SBG_LOG_WARNING(format, ...) ((void)sizeof(SBG_LOG_WARNING_CALL(format, ## __VA_ARGS__), 0))
88 #endif
89 
94 #define SBG_LOG_INFO_CALL(format, ...) sbgPlatformDebugLogMsg((const char*)__BASE_FILE__, (const char*)__func__, __LINE__, SBG_DEBUG_LOG_CATEGORY, SBG_DEBUG_LOG_TYPE_INFO, SBG_NO_ERROR, format, ##__VA_ARGS__)
95 
96 #if SBG_CONFIG_ENABLE_LOG_INFO == 1
97  #define SBG_LOG_INFO SBG_LOG_INFO_CALL
98 #else
99  #define SBG_LOG_INFO(format, ...) ((void)sizeof(SBG_LOG_INFO_CALL(format, ## __VA_ARGS__), 0))
100 #endif
101 
106 #define SBG_LOG_DEBUG_CALL(format, ...) sbgPlatformDebugLogMsg((const char*)__BASE_FILE__, (const char*)__func__, __LINE__, SBG_DEBUG_LOG_CATEGORY, SBG_DEBUG_LOG_TYPE_DEBUG, SBG_NO_ERROR, format, ##__VA_ARGS__)
107 
108 #if SBG_CONFIG_ENABLE_LOG_DEBUG == 1
109  #define SBG_LOG_DEBUG SBG_LOG_DEBUG_CALL
110 #else
111  #define SBG_LOG_DEBUG(format, ...) ((void)sizeof(SBG_LOG_DEBUG_CALL(format, ## __VA_ARGS__), 0))
112 #endif
113 
114 //----------------------------------------------------------------------//
115 //- Inline functions -//
116 //----------------------------------------------------------------------//
117 
125 {
126  const char *pString;
127 
128  switch (logType)
129  {
131  pString = "error";
132  break;
134  pString = "warning";
135  break;
137  pString = "info";
138  break;
140  pString = "debug";
141  break;
142  default:
143  pString = "unknown";
144  break;
145  }
146 
147  return pString;
148 }
149 
150 //----------------------------------------------------------------------//
151 //- Public functions -//
152 //----------------------------------------------------------------------//
153 
161 void sbgDebugHexDump(const char *pPrefix, const void *pBuffer, size_t size);
162 
163 #endif /* SBG_DEBUG_H */
void sbgDebugHexDump(const char *pPrefix, const void *pBuffer, size_t size)
_SbgDebugLogType
Definition: sbgDebug.h:53
@ SBG_DEBUG_LOG_TYPE_DEBUG
Definition: sbgDebug.h:57
@ SBG_DEBUG_LOG_TYPE_ERROR
Definition: sbgDebug.h:54
@ SBG_DEBUG_LOG_TYPE_WARNING
Definition: sbgDebug.h:55
@ SBG_DEBUG_LOG_TYPE_INFO
Definition: sbgDebug.h:56
SBG_INLINE const char * sbgDebugLogTypeToStr(SbgDebugLogType logType)
Definition: sbgDebug.h:124
enum _SbgDebugLogType SbgDebugLogType
Header file that contains all common definitions.
#define SBG_INLINE
Definition: sbgDefines.h:227