32#define MM_X64_VAL(value) ((uint32_t)(value >> 32)), ((uint32_t)value)
35#define MM_X64_FMT "%08lx%08lx"
47#define MM_MAC_ADDR_VAL(value) \
48 ((value)[0]), ((value)[1]), ((value)[2]), ((value)[3]), ((value)[4]), ((value)[5])
51#define MM_MAC_ADDR_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
85#if defined(MMLOG_LEVEL_OVRD)
86#define MMLOG_LEVEL MMLOG_LEVEL_OVRD
87#elif defined(MMLOG_LEVEL_DEFAULT)
88#define MMLOG_LEVEL MMLOG_LEVEL_DEFAULT
91#define MMLOG_LEVEL MMLOG_LEVEL_ERR
95#define MMLOG_LEVEL_INVALID (0)
97#define MMLOG_LEVEL_OFF (1)
99#define MMLOG_LEVEL_APP (2)
101#define MMLOG_LEVEL_ERR (3)
103#define MMLOG_LEVEL_WRN (4)
105#define MMLOG_LEVEL_INF (5)
107#define MMLOG_LEVEL_DBG (6)
109#define MMLOG_LEVEL_VRB (7)
113#define MMLOG_COLOR_RED (31)
115#define MMLOG_COLOR_GREEN (32)
117#define MMLOG_COLOR_ORANGE (33)
119#define MMLOG_COLOR_BLUE (34)
121#define MMLOG_COLOR_PURPLE (35)
123#define MMLOG_COLOR_CYAN (36)
125#define MMLOG_COLOR_LIGHT_GRAY (37)
127#if defined(MMLOG_COLOR_ENABLED) && MMLOG_COLOR_ENABLED
132#ifndef MMLOG_PREFIX_FMT
133#define MMLOG_PREFIX_FMT "\x1b[0;%um%c %8lu %s %s[%d] "
136#ifndef MMLOG_PREFIX_ARGS
137#define MMLOG_PREFIX_ARGS col, lvl, mmosal_get_time_ms(), short_task_name, __func__, __LINE__
140#ifndef MMLOG_SUFFIX_FMT
141#define MMLOG_SUFFIX_FMT "\x1b[0m"
147#ifndef MMLOG_APP_PREFIX_FMT
148#define MMLOG_APP_PREFIX_FMT "\x1b[1;37m %8lu "
151#ifndef MMLOG_APP_PREFIX_ARGS
152#define MMLOG_APP_PREFIX_ARGS mmosal_get_time_ms()
155#ifndef MMLOG_APP_SUFFIX_FMT
156#define MMLOG_APP_SUFFIX_FMT "\x1b[0m"
164#ifndef MMLOG_PREFIX_FMT
166#define MMLOG_PREFIX_FMT "%c %8lu %s %s[%d] "
169#ifndef MMLOG_PREFIX_ARGS
171#define MMLOG_PREFIX_ARGS lvl, mmosal_get_time_ms(), short_task_name, __func__, __LINE__
174#ifndef MMLOG_SUFFIX_FMT
176#define MMLOG_SUFFIX_FMT
182#ifndef MMLOG_APP_PREFIX_FMT
184#define MMLOG_APP_PREFIX_FMT " %8lu "
187#ifndef MMLOG_APP_PREFIX_ARGS
189#define MMLOG_APP_PREFIX_ARGS mmosal_get_time_ms()
192#ifndef MMLOG_APP_SUFFIX_FMT
194#define MMLOG_APP_SUFFIX_FMT
227#if MMLOG_LEVEL == MMLOG_LEVEL_INVALID
228#error Invalid value of MMLOG_LEVEL
233#define MMLOG_PRINTF(...) mmosal_printf(__VA_ARGS__)
236#if MMLOG_LEVEL >= MMLOG_LEVEL_APP
238#define MMLOG_APP(fmt, ...) \
239 MMLOG_PRINTF(MMLOG_APP_PREFIX_FMT fmt MMLOG_APP_SUFFIX_FMT, \
240 MMLOG_APP_PREFIX_ARGS, \
243#define MMLOG_APP(fmt, ...) printf_blackhole(fmt, ##__VA_ARGS__)
246#if MMLOG_LEVEL >= MMLOG_LEVEL_ERR
248#define MMLOG(fmt, _col, _lvl, ...) \
252 char short_task_name[3] = { '?', '?', '\0' }; \
253 const char *task_name = mmosal_task_name(); \
254 if (task_name != NULL) \
256 short_task_name[0] = task_name[0]; \
257 short_task_name[1] = task_name[1]; \
261 (void)(short_task_name); \
262 MMLOG_PRINTF(MMLOG_PREFIX_FMT fmt MMLOG_SUFFIX_FMT, MMLOG_PREFIX_ARGS, ##__VA_ARGS__); \
266#define MMLOG_ERR(fmt, ...) MMLOG(fmt, MMLOG_COLOR_RED, 'E', ##__VA_ARGS__)
268#define MMLOG_DUMP_ERR(title, buf, len) mm_hexdump('E', __func__, __LINE__, (title), (buf), (len))
271#define MMLOG_ERR(fmt, ...) printf_blackhole(fmt, ##__VA_ARGS__)
273#define MMLOG_DUMP_ERR(title, buf, len) mm_hexdump_blackhole(title, buf, len)
276#if MMLOG_LEVEL >= MMLOG_LEVEL_WRN
278#define MMLOG_WRN(fmt, ...) MMLOG(fmt, MMLOG_COLOR_ORANGE, 'W', ##__VA_ARGS__)
280#define MMLOG_DUMP_WRN(title, buf, len) mm_hexdump('W', __func__, __LINE__, (title), (buf), (len))
283#define MMLOG_WRN(fmt, ...) printf_blackhole(fmt, ##__VA_ARGS__)
285#define MMLOG_DUMP_WRN(title, buf, len) mm_hexdump_blackhole(title, buf, len)
288#if MMLOG_LEVEL >= MMLOG_LEVEL_INF
290#define MMLOG_INF(fmt, ...) MMLOG(fmt, MMLOG_COLOR_LIGHT_GRAY, 'I', ##__VA_ARGS__)
292#define MMLOG_DUMP_INF(title, buf, len) mm_hexdump('I', __func__, __LINE__, (title), (buf), (len))
295#define MMLOG_INF(fmt, ...) printf_blackhole(fmt, ##__VA_ARGS__)
297#define MMLOG_DUMP_INF(title, buf, len) mm_hexdump_blackhole(title, buf, len)
300#if MMLOG_LEVEL >= MMLOG_LEVEL_DBG
302#define MMLOG_DBG(fmt, ...) MMLOG(fmt, MMLOG_COLOR_GREEN, 'D', ##__VA_ARGS__)
304#define MMLOG_DUMP_DBG(title, buf, len) mm_hexdump('D', __func__, __LINE__, (title), (buf), (len))
307#define MMLOG_DBG(fmt, ...) printf_blackhole(fmt, ##__VA_ARGS__)
309#define MMLOG_DUMP_DBG(title, buf, len) mm_hexdump_blackhole(title, buf, len)
312#if MMLOG_LEVEL >= MMLOG_LEVEL_VRB
314#define MMLOG_VRB(fmt, ...) MMLOG(fmt, MMLOG_COLOR_PURPLE, 'V', ##__VA_ARGS__)
316#define MMLOG_DUMP_VRB(title, buf, len) mm_hexdump('V', __func__, __LINE__, (title), (buf), (len))
319#define MMLOG_VRB(fmt, ...) printf_blackhole(fmt, ##__VA_ARGS__)
321#define MMLOG_DUMP_VRB(title, buf, len) mm_hexdump_blackhole(title, buf, len)
static void mm_hexdump_blackhole(const char *title, const uint8_t *buf, size_t len)
Black hole version of mm_hexdump() to ensure arguments are referenced when a given log level is disab...
void mm_logging_init(void)
Initialize Morse logging API.
void mm_hexdump(char level, const char *function, unsigned line_number, const char *title, const uint8_t *buf, size_t len)
Dumps a binary buffer in hex.
static int printf_blackhole(const char *fmt,...)
Black hole printf to ensure arguments are referenced when a given log level is disabled.
char buf[1408]
Statically allocated buffer for HTTP GET request, just under 1 packet size.