You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.4 KiB
57 lines
2.4 KiB
#pragma once
|
|
#include "zbase.h"
|
|
|
|
extern bool g_xs_enable_log;
|
|
extern uint32_t zget_ticket(void);
|
|
extern void zdelay_ms(int ms);
|
|
|
|
#define ZLOG_RELEASE(TAG, fmt, ...) \
|
|
if (g_xs_enable_log) { \
|
|
zlog(TAG "" fmt "\n", ##__VA_ARGS__); \
|
|
}
|
|
#define ZLOGI(TAG, fmt, ...) \
|
|
if (g_xs_enable_log) { \
|
|
zlog("INFO [%-8s] " fmt "\n", TAG, ##__VA_ARGS__); \
|
|
}
|
|
#define ZLOGD(TAG, fmt, ...) \
|
|
if (g_xs_enable_log && enDebugFlag) { \
|
|
zlog("%08lu DEBU [%-8s] " fmt "\n", zget_ticket(), TAG, ##__VA_ARGS__); \
|
|
}
|
|
#define ZLOGE(TAG, fmt, ...) \
|
|
if (g_xs_enable_log) { \
|
|
zlog("【 ERRO 】 [%-8s] " fmt "\n", TAG, ##__VA_ARGS__); \
|
|
}
|
|
|
|
#define ZLOGW(TAG, fmt, ...) \
|
|
if (g_xs_enable_log) { \
|
|
zlog("%08lu WARN [%-8s] " fmt "\n", zget_ticket(), TAG, ##__VA_ARGS__); \
|
|
}
|
|
|
|
#define ASSERT(cond, info) \
|
|
if (!(cond)) { \
|
|
while (1) { \
|
|
zlog("ASSERT: %s [%s:%d] %s\n", #cond, __FILE__, __LINE__, info); \
|
|
} \
|
|
}
|
|
|
|
#define ZASSERT_INFO(cond, fmt, ...) \
|
|
if (!(cond)) { \
|
|
while (1) { \
|
|
zlog("ASSERT: %s [%s:%d]" fmt "\n", #cond, __FILE__, __LINE__, ##__VA_ARGS__); \
|
|
} \
|
|
}
|
|
|
|
#define ZASSERT(cond) ASSERT(cond, "")
|
|
#define ZASSERT(cond) ASSERT(cond, "")
|
|
#define HAL_ASSERT(exptr) \
|
|
{ \
|
|
HAL_StatusTypeDef status = (exptr); \
|
|
ASSERT(status == HAL_OK, #exptr); \
|
|
}
|
|
|
|
#define ZARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
|
|
|
|
void zlog_init(UART_HandleTypeDef* uart);
|
|
void zlog(const char* fmt, ...);
|
|
void zlog_raw(const char* info);
|
|
void zlog_enable(bool enable);
|