#ifndef __LOGGER_H__
|
#define __LOGGER_H__
|
|
#include <stdarg.h>
|
|
#define OS_LOG_NONE 0 /* Set rollback size to 0 will not rollback */
|
|
typedef enum
|
{
|
LOG_LEVEL_DISB = 0, /* Disable "Debug" */
|
LOG_LEVEL_FATAL, /* Debug Level "Fatal" */
|
LOG_LEVEL_ERROR, /* Debug Level "ERROR" */
|
LOG_LEVEL_WARN, /* Debug Level "warnning" */
|
LOG_LEVEL_NRML, /* Debug Level "Normal" */
|
LOG_LEVEL_DEBUG, /* Debug Level "Debug" */
|
LOG_LEVEL_INFO, /* Debug Level "Information" */
|
LOG_LEVEL_TRACE, /* Debug Level "Trace" */
|
LOG_LEVEL_MAX,
|
}dbg_level_e;
|
|
typedef enum
|
{
|
DEBUG_NONE = 0, /* ²»½øÈëdebug */
|
DEBUG_MODE /* debug ģʽ*/
|
} DebugMode_e;
|
|
|
#define TH_EXPORT
|
#define TH_VSNPRINTF vsnprintf
|
#define TH_SNPRINTF snprintf /* int snprintf(char *str, size_t size, const char *format, ...); */
|
|
|
//¶¨ÒåÑÕÉ«
|
#define COLOR_NORMAL "\033[0m"
|
#define COLOR_BLACK "\033[0;40;30m"
|
#define COLOR_RED "\033[0;40;31m"
|
#define COLOR_LRED "\033[1;40;31m" /* ¸ßÁÁ*/
|
#define COLOR_GREEN "\033[0;40;32m"
|
#define COLOR_YELLOW "\033[0;40;33m"
|
#define COLOR_LYELLOW "\033[1;40;33m"
|
#define COLOR_BLUE "\033[0;40;34m"
|
#define COLOR_PURPLE "\033[0;40;35m"
|
#define COLOR_CYAN "\033[0;40;36m"
|
#define COLOR_LCYAN "\033[1;40;36m"
|
#define COLOR_WHILE "\033[0;40;37m"
|
|
//¶¨Òå´òÓ¡¼¶±ð
|
#define TH_PRINT_DEBUG 0 /* µ÷ÊÔÓõÄÐÅÏ¢ */
|
#define TH_PRINT_INFO 1 /* ¸æÖªÏµÍ³Õý³£Ê¼þµÄÏûÏ¢ */
|
#define TH_PRINT_PRIMA 2 /* ÏÔʾÖ÷ÒªµÄÊý¾ÝÄÚÈÝ*/
|
#define TH_PRINT_ALERT 3 /* δÓà */
|
#define TH_PRINT_WARN 4 /* Òò½»»¥¶Ô·½Ìṩ²»ÕýÈ·µÄÊý¾ÝÒý·¢µÄ´íÎó */
|
#define TH_PRINT_EMERG 5 /* ºËÐIJã(CORE)´íÎó,Çý¶¯,²Ù×÷ϵͳ,Îļþ¶Áд´íÎó */
|
#define TH_PRINT_FAIL 6 /* Òò»·¾³ÒòËØÒý·¢µÄ´íÎó(Ôٴγ¢ÊÔ¿ÉÄܳɹ¦,ÈçÍøÂç)*/
|
#define TH_PRINT_ERR 7 /* Âß¼²ã(¹¦ÄÜ¿â»òÓ¦Óÿâ)ÌáʾµÄϵͳÐÔ´íÎó */
|
#define TH_PRINT_MAX 8 /* ×î´ó¼¶±ð */
|
|
//¶¨Ò嵱ǰ´òÓ¡¼¶±ð
|
//µÍÓÚTH_PRINT_CUR¼¶±ðµÄ´òÓ¡ÐÅÏ¢£¬½«²»±»±àÒëµ½¿âÎļþÖС£
|
#define TH_PRINT_CUR TH_PRINT_INFO
|
|
#if TH_PRINT_DEBUG>=TH_PRINT_CUR
|
#define DebugPrintf(pstrMod,args...) \
|
Board_DebugPrintf(COLOR_WHILE,pstrMod,TH_PRINT_DEBUG,"!!!!!","",__LINE__,__FUNCTION__,##args)
|
#else
|
#define DebugPrintf(pstrMod,args...)
|
#endif
|
|
#if TH_PRINT_INFO>=TH_PRINT_CUR
|
#define InforPrintf(pstrMod,args...) \
|
Board_DebugPrintf(COLOR_GREEN,pstrMod,TH_PRINT_INFO,"info","",__LINE__,__FUNCTION__,##args)
|
#else
|
#define InforPrintf(pstrMod,args...)
|
#endif
|
|
#if TH_PRINT_PRIMA>=TH_PRINT_CUR
|
#define PrimaPrintf(pstrMod,args...) \
|
Board_DebugPrintf(COLOR_LYELLOW,pstrMod,TH_PRINT_PRIMA,"prima","",__LINE__,__FUNCTION__,##args)
|
#else
|
#define PrimaPrintf(pstrMod,args...)
|
#endif
|
|
|
#if TH_PRINT_FAIL>=TH_PRINT_CUR
|
#define FailPrintf(pstrMod,args...) \
|
Board_DebugPrintf(COLOR_RED,pstrMod,TH_PRINT_FAIL,"fail","",__LINE__,__FUNCTION__,##args)
|
#else
|
#define FailPrintf(pstrMod,args...)
|
#endif
|
|
#if TH_PRINT_WARN>=TH_PRINT_CUR
|
#define WarningPrintf(pstrMod,args...) \
|
Board_DebugPrintf(COLOR_YELLOW,pstrMod,TH_PRINT_WARN,"warning","",__LINE__,__FUNCTION__,##args)
|
#else
|
#define WarningPrintf(pstrMod,args...)
|
#endif
|
|
#if TH_PRINT_ERR>=TH_PRINT_CUR
|
#define ErrorPrintf(pstrMod,args...) \
|
Board_DebugPrintf(COLOR_LRED,pstrMod,TH_PRINT_ERR,"error","",__LINE__,__FUNCTION__,##args)
|
#else
|
#define ErrorPrintf(pstrMod,args...)
|
#endif
|
|
#if TH_PRINT_ALERT>=TH_PRINT_CUR
|
#define AlertPrintf(pstrMod,args...) \
|
Board_DebugPrintf(COLOR_CYAN,pstrMod,TH_PRINT_ALERT,"alert","",__LINE__,__FUNCTION__,##args)
|
#else
|
#define AlertPrintf(pstrMod,args...)
|
#endif
|
|
#define NonePrintf(pstrMod,args...) \
|
Board_DebugPrintf(COLOR_NORMAL,pstrMod,TH_PRINT_MAX,"none","",__LINE__,__FUNCTION__,##args)
|
|
/*
|
* º¯Êý¶¨Òå
|
* ÄÚ²¿Ä£¿éʹÓÃ
|
* ¶¨Òåµ÷ÊÔ´òÓ¡º¯Êý
|
*/
|
#define ES800_DebugPrint(args,sz...) DebugPrintf("ES800",args,##sz)
|
#define ES800_InforPrint(args,sz...) InforPrintf("ES800",args,##sz)
|
#define ES800_PrimaPrint(args,sz...) PrimaPrintf("ES800",args,##sz)
|
#define ES800_FailPrint(args,sz...) FailPrintf("ES800",args,##sz)
|
#define ES800_WarningPrint(args,sz...) WarningPrintf("ES800",args,##sz)
|
#define ES800_ErrorPrint(args,sz...) ErrorPrintf("ES800",args,##sz)
|
#define ES800_AlertPrint(args,sz...) AlertPrintf("ES800",args,##sz)
|
#define ES800_NonePrint(args,sz...) NonePrintf("ES800",args,##sz)
|
|
void Board_DebugInit(int Level);
|
void Board_DebugDeInit(void);
|
void Board_DebugPrintf(char *Color, char *Module, int Level, char *LevelName, char *FileName, int LineNum, const char *Func, char *Fmt, ...);
|
|
#endif /* End of __LOGGER_H__ */
|