/** ****************************************************************************** * @file debug_log.h * @brief 增强型调试日志系统头文件 * @author Application Layer * @version 1.0 ****************************************************************************** * @attention * 本模块实现增强型调试日志系统 * 设计依据:多通信接口统一指令处理系统开发计划 第3.4节 * * 日志格式:[LEVEL][MODULE] message * 示例:[INFO][CMD] Command received: RL ****************************************************************************** */ #ifndef __DEBUG_LOG_H #define __DEBUG_LOG_H #ifdef __cplusplus extern "C" { #endif #include #include typedef enum { LOG_LEVEL_DEBUG = 0, LOG_LEVEL_INFO = 1, LOG_LEVEL_WARN = 2, LOG_LEVEL_ERROR = 3, LOG_LEVEL_NONE = 4 } log_level_t; void DebugLog_Init(void); void DebugLog_SetLevel(log_level_t level); log_level_t DebugLog_GetLevel(void); void DebugLog_EnableModule(const char *module, bool enable); void DebugLog_Output(log_level_t level, const char *module, const char *fmt, ...); #define LOG_DEBUG(module, fmt, ...) \ DebugLog_Output(LOG_LEVEL_DEBUG, module, fmt, ##__VA_ARGS__) #define LOG_INFO(module, fmt, ...) \ DebugLog_Output(LOG_LEVEL_INFO, module, fmt, ##__VA_ARGS__) #define LOG_WARN(module, fmt, ...) \ DebugLog_Output(LOG_LEVEL_WARN, module, fmt, ##__VA_ARGS__) #define LOG_ERROR(module, fmt, ...) \ DebugLog_Output(LOG_LEVEL_ERROR, module, fmt, ##__VA_ARGS__) #ifdef __cplusplus } #endif #endif