guowenxue
2024-06-25 8b691b645fb73d244b46dfa6f094ec299b202f67
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#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__ */