|
Wirepas SDK
|
|
Go to the documentation of this file.
59 #define Print_Log(fmt, ...) UartPrint_printf(fmt, ##__VA_ARGS__)
60 #ifndef DEBUG_LOG_UART_BAUDRATE
61 #define DEBUG_LOG_UART_BAUDRATE 115200
63 #define LOG_INIT() UartPrint_init(DEBUG_LOG_UART_BAUDRATE)
65 #define Print_Log(fmt, ...)
74 #ifndef DEBUG_LOG_MAX_LEVEL
76 #define DEBUG_LOG_MAX_LEVEL LVL_ERROR
91 #define LVL_STRING_4 "D"
92 #define LVL_STRING_3 "I"
93 #define LVL_STRING_2 "W"
94 #define LVL_STRING_1 "E"
95 #define LVL_STRING_0 ""
100 #define DEBUG_LVL_TO_STRING(level) LVL_STRING_##level
105 #define FLUSH_DELAY_MS 45
108 #ifndef DEBUG_LOG_CUSTOM
109 # ifndef DEBUG_LOG_MODULE_NAME
111 # error "No module name set for logger"
114 # define DEBUG_LOG_PRINT_MODULE_NAME
115 # define DEBUG_LOG_PRINT_TIME
116 # define DEBUG_LOG_PRINT_LEVEL
117 # undef DEBUG_LOG_PRINT_FUNCTION
118 # undef DEBUG_LOG_PRINT_LINE
122 #ifdef DEBUG_LOG_PRINT_MODULE_NAME
123 # define S_MOD_NAME_PREFIX "["DEBUG_LOG_MODULE_NAME"]"
125 # define S_MOD_NAME_PREFIX
128 #ifdef DEBUG_LOG_PRINT_TIME_HP
129 # define S_TIME_PREFIX "[%09u]"
130 # define S_TIME_SUFFIX , lib_time->getTimestampHp()
131 #elif defined(DEBUG_LOG_PRINT_TIME_MS)
132 # define S_TIME_PREFIX "[%09u]"
133 # define S_TIME_SUFFIX , (lib_time->getTimestampCoarse() * 125) >> 4
134 #elif defined(DEBUG_LOG_PRINT_TIME)
135 # define S_TIME_PREFIX "[%09u]"
136 # define S_TIME_SUFFIX , lib_time->getTimestampCoarse()
138 # define S_TIME_PREFIX
139 # define S_TIME_SUFFIX
142 #ifdef DEBUG_LOG_PRINT_LEVEL
143 # define S_LEVEL_PREFIX(level) " "DEBUG_LVL_TO_STRING(level)": "
145 # define S_LEVEL_PREFIX(level)
148 #ifdef DEBUG_LOG_PRINT_FUNCTION
149 # define S_FUNCTION_PREFIX "func:%s, "
150 # define S_FUNCTION_SUFFIX , __FUNCTION__
152 # define S_FUNCTION_PREFIX
153 # define S_FUNCTION_SUFFIX
156 #ifdef DEBUG_LOG_PRINT_LINE
157 # define S_LINE_PREFIX "line: %03d, "
158 # define S_LINE_SUFFIX , __LINE__
160 # define S_LINE_PREFIX
161 # define S_LINE_SUFFIX
175 #define LOG(level, fmt, ...) \
177 ((uint8_t) level) <= ((uint8_t) DEBUG_LOG_MAX_LEVEL) ? \
179 S_MOD_NAME_PREFIX S_TIME_PREFIX S_LEVEL_PREFIX(level) \
180 S_FUNCTION_PREFIX S_LINE_PREFIX \
181 fmt"\n" S_TIME_SUFFIX S_FUNCTION_SUFFIX S_LINE_SUFFIX \
196 #define LOG_BUFFER(level, buffer, size) \
198 if(((uint8_t) level) <= ((uint8_t) DEBUG_LOG_MAX_LEVEL)) { \
199 for (uint8_t i = 0; i < size; i++) \
201 Print_Log("%02X ", buffer[i]); \
202 if ((i & 0xF) == 0xF && i != (uint8_t)(size-1)) \
216 #define LOG_FLUSH(level) \
218 if(((uint8_t) level) <= ((uint8_t) DEBUG_LOG_MAX_LEVEL)) { \
219 app_lib_time_timestamp_hp_t end; \
220 end = lib_time->addUsToHpTimestamp(lib_time->getTimestampHp(), \
221 FLUSH_DELAY_MS * 1000); \
222 while (lib_time->isHpTimestampBefore(lib_time->getTimestampHp(),end)); \