From 42cdf46a019bcdb382d4192570f19fe5240ada42 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 29 Jun 2024 15:04:23 +0800 Subject: [PATCH] update --- logger.h | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/logger.h b/logger.h index 1e4cc8d..d6dd614 100644 --- a/logger.h +++ b/logger.h @@ -5,29 +5,29 @@ #include "cmsis_os.h" #include "main.h" extern bool g_enable_log; -#define ZLOG_RELEASE(TAG, fmt, ...) \ +#define ZLOG_RELEASE(TAG, fmt, ...) \ if (g_enable_log) { \ zlog(TAG "" fmt "\n", ##__VA_ARGS__); \ } -#define ZLOGI(TAG, fmt, ...) \ +#define ZLOGI(TAG, fmt, ...) \ if (g_enable_log) { \ zlog("%08lu INFO [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \ } -#define ZLOGD(TAG, fmt, ...) \ +#define ZLOGD(TAG, fmt, ...) \ if (g_enable_log) { \ zlog("%08lu DEBU [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \ } -#define ZLOGE(TAG, fmt, ...) \ +#define ZLOGE(TAG, fmt, ...) \ if (g_enable_log) { \ zlog("%08lu ERRO [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \ } -#define ZLOGW(TAG, fmt, ...) \ +#define ZLOGW(TAG, fmt, ...) \ if (g_enable_log) { \ zlog("%08lu WARN [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \ } -#define ZASSERT(cond) \ +#define ZASSERT(cond) \ if (!(cond)) { \ while (1) { \ zlog("ASSERT: %s [%s:%d]\n", #cond, __FILE__, __LINE__); \ @@ -35,12 +35,18 @@ extern bool g_enable_log; } \ } -#define ZASSERT_INFO(cond, info) \ - if (!(cond)) { \ - while (1) { \ +#define ZASSERT_INFO(cond, info) \ + if (!(cond)) { \ + while (1) { \ zlog("ASSERT: %s [%s:%d] %s\n", #cond, __FILE__, __LINE__, info); \ - osDelay(1000); \ - } \ + osDelay(1000); \ + } \ + } + +#define ZEARLY_ASSERT(cond) \ + if (!(cond)) { \ + while (1) { \ + } \ } void zlog(const char* fmt, ...);