RTU_ALL_AI/release/inc/myLog.h

38 lines
1.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file myLog.h
* @brief 异步日志系统接口(纯 C
*/
#ifndef _MY_LOG_H_
#define _MY_LOG_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
#define LOG_INFO 0
#define LOG_ERROR 1
/** 初始化(首次调用 log_prt 时自动触发,也可手动调用) */
int log_init(const char *dir);
/** 核心日志函数(非阻塞,消息入队后立即返回) */
void log_prt(uint32_t level, const char *file, const char *func,
uint32_t line, const char *fmt, ...);
void log_file_on(void); /* 开启文件写入 */
void log_file_off(void); /* 关闭文件写入 */
void log_console_on(void); /* 开启控制台输出 */
void log_console_off(void); /* 关闭控制台输出 */
void log_flush(void); /* 等待队列清空 */
void log_cleanup(void); /* 停止线程、释放资源 */
#define LOG_I(fmt, ...) log_prt(LOG_INFO, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
#define LOG_E(fmt, ...) log_prt(LOG_ERROR, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
#ifdef __cplusplus
}
#endif
#endif