|
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
107 #ifndef DEBUG_LOG_CUSTOM
108 # ifndef DEBUG_LOG_MODULE_NAME
110 # error "No module name set for logger"
113 # define DEBUG_LOG_PRINT_MODULE_NAME
114 # define DEBUG_LOG_PRINT_TIME
115 # define DEBUG_LOG_PRINT_LEVEL
116 # undef DEBUG_LOG_PRINT_FUNCTION
117 # undef DEBUG_LOG_PRINT_LINE
121 #ifdef DEBUG_LOG_PRINT_MODULE_NAME
122 # define S_MOD_NAME_PREFIX "["DEBUG_LOG_MODULE_NAME"]"
124 # define S_MOD_NAME_PREFIX
127 #ifdef DEBUG_LOG_PRINT_TIME_HP
128 # define S_TIME_PREFIX "[%09u]"
129 # define S_TIME_SUFFIX , lib_time->getTimestampHp()
130 #elif defined(DEBUG_LOG_PRINT_TIME_MS)
131 # define S_TIME_PREFIX "[%09u]"
132 # define S_TIME_SUFFIX , (lib_time->getTimestampCoarse() * 125) >> 4
133 #elif defined(DEBUG_LOG_PRINT_TIME)
134 # define S_TIME_PREFIX "[%09u]"
135 # define S_TIME_SUFFIX , lib_time->getTimestampCoarse()
137 # define S_TIME_PREFIX
138 # define S_TIME_SUFFIX
141 #ifdef DEBUG_LOG_PRINT_LEVEL
142 # define S_LEVEL_PREFIX(level) " "DEBUG_LVL_TO_STRING(level)": "
144 # define S_LEVEL_PREFIX(level)
147 #ifdef DEBUG_LOG_PRINT_FUNCTION
148 # define S_FUNCTION_PREFIX "func:%s, "
149 # define S_FUNCTION_SUFFIX , __FUNCTION__
151 # define S_FUNCTION_PREFIX
152 # define S_FUNCTION_SUFFIX
155 #ifdef DEBUG_LOG_PRINT_LINE
156 # define S_LINE_PREFIX "line: %03d, "
157 # define S_LINE_SUFFIX , __LINE__
159 # define S_LINE_PREFIX
160 # define S_LINE_SUFFIX
173 #define LOG(level, fmt, ...) \
175 ((uint8_t) level) <= ((uint8_t) DEBUG_LOG_MAX_LEVEL) ? \
177 S_MOD_NAME_PREFIX S_TIME_PREFIX S_LEVEL_PREFIX(level) \
178 S_FUNCTION_PREFIX S_LINE_PREFIX \
179 fmt"\n" S_TIME_SUFFIX S_FUNCTION_SUFFIX S_LINE_SUFFIX \
191 #define LOGE(fmt, ...) LOG(LVL_ERROR, fmt __VA_OPT__(,) __VA_ARGS__)
192 #define LOGW(fmt, ...) LOG(LVL_WARNING, fmt __VA_OPT__(,) __VA_ARGS__)
193 #define LOGI(fmt, ...) LOG(LVL_INFO, fmt __VA_OPT__(,) __VA_ARGS__)
194 #define LOGD(fmt, ...) LOG(LVL_DEBUG, fmt __VA_OPT__(,) __VA_ARGS__)
206 #define LOG_BUFFER(level, buffer, size) \
208 if(((uint8_t) level) <= ((uint8_t) DEBUG_LOG_MAX_LEVEL)) { \
209 for (uint16_t i = 0; i < size; i++) \
211 Print_Log("%02X ", buffer[i]); \
212 if ((i & 0xF) == 0xF && i != (uint8_t)(size-1)) \
226 #define LOG_FLUSH(level) \
228 if(((uint8_t) level) <= ((uint8_t) DEBUG_LOG_MAX_LEVEL)) { \
229 app_lib_time_timestamp_hp_t end; \
230 end = lib_time->addUsToHpTimestamp(lib_time->getTimestampHp(), \
231 FLUSH_DELAY_MS * 1000); \
232 while (lib_time->isHpTimestampBefore(lib_time->getTimestampHp(),end)); \