| #ifndef __LIBLOG_H__ |
| #define __LIBLOG_H__ |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| //Log模块是否使能 |
| #define LOG_ENABLE 1 |
| |
| |
| #if LOG_ENABLE |
| |
| #define ENABLE(X) (1<<(X)) |
| |
| //****************************************************************************// |
| //*************************User configuration start**************************// |
| //****************************************************************************// |
| |
| typedef enum |
| { |
| LOG_VERBOSE = 0, //从0开始,自行添加 |
| LOG_ERROR, |
| LOG_WARNING, |
| LOG_INFO, |
| LOG_DEBUG, |
| LOG_LEVEL_MAX//不可删除 |
| }log_level_enum; |
| |
| typedef enum |
| { |
| LOG_OTHERS = 0, //从0开始,自行添加 |
| LOG_MQTT, |
| LOG_SPI, |
| LOG_THREADTEST_DBUS, |
| LOG_THREADHANDLE, |
| LOG_HTTP, |
| LOG_FTP, |
| LOG_TAG_MAX, //不可删除 |
| } log_tag_enum; |
| |
| |
| typedef struct |
| { |
| char open_log_level; |
| char open_module_log_num; |
| char open_module_log[LOG_TAG_MAX]; |
| }log_level_str; |
| |
| |
| //Log等级全局使能 ENABLE(LOG_VERBOSE)添加此条件控制是否只执行优先级高的:添加则为只要在模块内调用的都打印,不添加则为执行模块优先级最高的 |
| #define LOG_LEVEL_ENABLE ENABLE(LOG_VERBOSE) |
| //#define LOG_LEVEL_ENABLE ENABLE(LOG_VERBOSE)|ENABLE(LOG_DEBUG)|ENABLE(LOG_INFO)|ENABLE(LOG_WARNING)|ENABLE(LOG_ERROR) |
| |
| |
| //根据Tag枚举索引排序 |
| static unsigned int LogTagEnableInfoTable[LOG_TAG_MAX] = |
| { |
| // ENABLE(LOG_VERBOSE)|ENABLE(LOG_DEBUG)|ENABLE(LOG_INFO)|ENABLE(LOG_WARNING)|ENABLE(LOG_ERROR), |
| // ENABLE(LOG_VERBOSE), |
| // ENABLE(LOG_VERBOSE), |
| // ENABLE(LOG_WARNING), |
| }; |
| |
| const static char * LogTagNameInfoTable[LOG_TAG_MAX] = |
| { |
| "OTHERS",\ |
| "MQTT",\ |
| "SPI",\ |
| "THREADTEST_DBUS",\ |
| "THREADHANDLE",\ |
| "HTTP",\ |
| "FTP", |
| }; |
| |
| const static char * LogLevelNameInfoTable[LOG_LEVEL_MAX] = |
| { |
| "[VERBOSE]","[ERROR]","[WARNING]","[INFO]","[DEBUG]" //lt add @2021.7.22 for [] |
| }; |
| |
| #endif //LOG_ENABLE |
| |
| void lynq_log_global_output(log_level_enum Level,const char *format,...); |
| |
| /********************************************************************************************************* |
| ** Function name: lynq_log_output |
| ** Description lynq_log_output |
| ** Input parameters: Tag:Tag类型(log_level_enum) |
| Level:Tag下打印level(log_tag_enum) |
| format:printf打印的不定长参数 |
| ** Returned value: None |
| ** Created by: |
| *********************************************************************************************************/ |
| void lynq_log_output(log_tag_enum Tag,log_level_enum Level,const char *format,...); |
| |
| /********************************************************************************************************* |
| ** Function name: lynq_update_log_output |
| ** Description ÖØÐ»ñÈ¡logµÈ¼¶²¢Ê¹ÆäÉúЧ |
| ** Input parameters: Tag:TagÀàÐÍ(log_level_enum) |
| Level:TagÏ´òÓ¡level(log_tag_enum) |
| format:printf´òÓ¡µÄ²»¶¨³¤²ÎÊý |
| ** Returned value: None |
| ** Created by: |
| *********************************************************************************************************/ |
| void lynq_update_log_output(log_tag_enum Tag,log_level_enum Level,const char *format,...); |
| |
| /********************************************************************************************************* |
| ** Function name: lynq_fget_log_level |
| ** Description 读取日志配置信息 |
| ** Input parameters: open_log_level:开启log日志等级 |
| open_module_log_num:开启日志模块的个数 |
| open_module_log:开启日子服务的模块 |
| ** Returned value: 0:成功,-1:失败 |
| ** Created by: |
| *********************************************************************************************************/ |
| int lynq_read_store_log_deploy(log_level_str *log_level_read_level_str); |
| |
| /********************************************************************************************************* |
| ** Function name: lynq_enable_log_serve |
| ** Description 使能日志服务 |
| ** Input parameters: None |
| ** Returned value: None |
| ** Created by: |
| *********************************************************************************************************/ |
| void lynq_log_printf_output(log_tag_enum Tag,log_level_enum Level,const char *format,...); |
| |
| |
| /******************************************************************************************************** |
| *********************************************************************************************************/ |
| |
| void lynq_log_configuration_set(char *log_name,char log_data_arr); |
| void lynq_log_configuration_init(char *log_name); |
| |
| void lynq_store_log_test(void); |
| void lynq_read_set_log_test(void); |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif //__LOG_H__ |