|
|
#pragma once
#include <stdbool.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" { #endif
#include "cmsis_os.h"
#include "main.h"
extern bool g_enable_log; #define ZLOG_RELEASE(TAG, fmt, ...) \
if (g_enable_log) { \ zlog(TAG "" fmt "\n", ##__VA_ARGS__); \ } #define ZLOGI(TAG, fmt, ...) \
if (g_enable_log) { \ zlog("%08lu INFO [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \ } #define ZLOGD(TAG, fmt, ...) \
if (g_enable_log) { \ zlog("%08lu DEBU [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \ } #define ZLOGE(TAG, fmt, ...) \
if (g_enable_log) { \ zlog("%08lu ERRO [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \ }
#define ZLOGW(TAG, fmt, ...) \
if (g_enable_log) { \ zlog("%08lu WARN [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \ }
#define ZASSERT(cond) \
if (!(cond)) { \ while (1) { \ zlog("ASSERT: %s [%s:%d]\n", #cond, __FILE__, __LINE__); \ osDelay(1000); \ } \ }
#define ZASSERT_INFO(cond, info) \
if (!(cond)) { \ while (1) { \ zlog("ASSERT: %s [%s:%d] %s\n", #cond, __FILE__, __LINE__, info); \ osDelay(1000); \ } \ }
#define ZEARLY_ASSERT(cond) \
if (!(cond)) { \ while (1) { \ } \ }
void zlog(const char* fmt, ...); void zlog_raw(const char* info); void zlog_init(UART_HandleTypeDef* huart); void zlog_enable(bool enable);
#ifdef __cplusplus
} #endif
|