##define定义 printf实现log的打印

/*
    如果需要打印调试信息 
    #define DEBUG_LOG_EN x
                         0/关闭所有调试信息 
                         1/只打开最高级 
                         2/打开高和中级 
                         3/全部打开
    LOG()                低级
    LOG_MID()            中级
    LOG_HIGH()           高级
    如果需要在某个文件中使用不同的显示等级,
    在那个c文件的最开头(包含debug头文件之前)
    定义DEBUG_LOG_EN的等级。
    默认显示等级可以在下面设置
*/
#ifndef DEBUG_LOG_EN
    #define DEBUG_LOG_EN 0 //设置默认显示等级
#endif

#if (DEBUG_LOG_EN==1)
    #define DEBUG_LOG_EN_HIGH
#endif
#if (DEBUG_LOG_EN==2)
    #define DEBUG_LOG_EN_HIGH
    #define DEBUG_LOG_EN_MID
#endif
#if (DEBUG_LOG_EN==3)
    #define DEBUG_LOG_EN_HIGH
    #define DEBUG_LOG_EN_MID
    #define DEBUG_LOG_EN_LOW
#endif

#ifdef  DEBUG_LOG_EN_LOW
    #define LOG(format,args...)    printf(format,##args)
#else   
    #define LOG(format,args...)     ((void)0)
#endif

#ifdef  DEBUG_LOG_EN_MID
    #define LOG_MID(format,args...)    printf(format,##args)
#else   
    #define LOG_MID(format,args...)    ((void)0)
#endif

#ifdef  DEBUG_LOG_EN_HIGH
    #define LOG_HIGH(format,args...)    printf(format,##args)
#else   
    #define LOG_HIGH(format,args...)    ((void)0)
#endif    
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐