wch-code/mijia_haier_bridge/src/user/util_log.h

43 lines
1.9 KiB
C

#ifndef __UTIL_LOG_H
#define __UTIL_LOG_H
#include "ch32v10x.h"
#include "bsp_tick.h"
#define CSI_START "\033["
#define CSI_END "\033[0m"
/* output log front color */
#define F_BLACK "30;"
#define F_RED "31;"
#define F_GREEN "32;"
#define F_YELLOW "33;"
#define F_BLUE "34;"
#define F_MAGENTA "35;"
#define F_CYAN "36;"
#define F_WHITE "37;"
/* output log background color */
#define B_NULL
#define B_BLACK "40;"
#define B_RED "41;"
#define B_GREEN "42;"
#define B_YELLOW "43;"
#define B_BLUE "44;"
#define B_MAGENTA "45;"
#define B_CYAN "46;"
#define B_WHITE "47;"
/* output log fonts style */
#define S_BOLD "1m"
#define S_UNDERLINE "4m"
#define S_BLINK "5m"
#define S_NORMAL "22m"
#define LOG_E(format, ...) log_uart_printf(CSI_START F_RED S_NORMAL "E/%s(%llu): " format CSI_END "\n", __func__, bsp_tick_get(), ##__VA_ARGS__)
#define LOG_W(format, ...) log_uart_printf(CSI_START F_YELLOW S_NORMAL "W/%s(%llu): " format CSI_END "\n", __func__, bsp_tick_get(), ##__VA_ARGS__)
#define LOG_I(format, ...) log_uart_printf(CSI_START F_GREEN S_NORMAL "I/%s(%llu): " format CSI_END "\n", __func__, bsp_tick_get(), ##__VA_ARGS__)
#define LOG_D(format, ...) log_uart_printf(CSI_START F_CYAN S_NORMAL "D/%s(%llu): " format CSI_END "\n", __func__, bsp_tick_get(), ##__VA_ARGS__)
void log_init(uint32_t baudrate);
void log_uart_printf(const char *fmt, ...);
#endif