#ifndef MYLOG_H #define MYLOG_H #include #ifdef __cplusplus extern "C" { #endif #define LOG_LEVEL_INFO 0 #define LOG_LEVEL_ERROR 1 #define LOG_LEVEL_MAX 2 // 日志函数 void log_prt(const uint32_t level, const char *file, const char *func, uint32_t line, const char *fmt, ...); void log_set_file_enabled(int enabled); // 设置文件日志开关 void log_set_console_enabled(int enabled); // 设置控制台日志开关 void log_flush(void); // 刷新日志 void log_cleanup(void); // 清理日志系统 // 便捷宏定义 #define LOG_I(fmt, ...) \ log_prt(LOG_LEVEL_INFO, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__) #define LOG_E(fmt, ...) \ log_prt(LOG_LEVEL_ERROR, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__) #ifdef __cplusplus } #endif #endif // MYLOG_H