1:
2:
3: /*************
4: * *
5: * SENTINEL *
6: * *
7: *************/
8:
9:
10: #ifndef WWWI_MIND_MINDLOG_H
11: #define WWWI_MIND_MINDLOG_H
12:
13:
14: /**********************
15: * *
16: * COMPILER INCLUDES *
17: * *
18: **********************/
19:
20:
21: #include <ostream>
22:
23:
24: /*********************
25: * *
26: * PROJECT INCLUDES *
27: * *
28: *********************/
29:
30:
31: #include "mind.h"
32: #include "wwwi/mutex.h"
33:
34:
35: using WWWI::Mutex;
36:
37:
38: /************
39: * *
40: * DEFINES *
41: * *
42: ************/
43:
44:
45: #ifdef DEBUG_ENABLED
46: #define DEBUG_LOG(XXX) MIND_LOG(XXX)
47: #define DEBUG_ONLY(XXX) XXX
48: #else
49: #define DEBUG_LOG(XXX)
50: #define DEBUG_ONLY(XXX)
51: #endif
52:
53: #define MIND_LOG(XXX) GetSingleton<MINDLog>()->Log(XXX)
54:
55:
56: /**********************
57: * *
58: * TYPE DECLARATIONS *
59: * *
60: **********************/
61:
62:
63: typedef enum { LF_UDP,
64: LF_CACHE,
65: LF_CEXPIRE,
66: LF_OBJNEWDEL,
67: LF_RESOLVER,
68: LF_MISC,
69: LF_PACKETFORMAT,
70: LF_THREADS,
71: LF_MAX
72: } LogFacility;
73:
74:
75: typedef enum { LY_EXTRA_DEBUG,
76: LY_DEBUG,
77: LY_INFO,
78: LY_ERROR,
79: LY_FAILURE
80: } LogPriority;
81:
82:
83: typedef enum { LM_TERMINAL,
84: LM_SYSLOG
85: } LogMethod;
86:
87:
88: /******************
89: * *
90: * CLASS MINDLOG *
91: * *
92: ******************/
93:
94:
95: class MINDLog {
96: public:
97: MINDLog(void);
98: void Log(LogFacility i_lf, LogPriority i_ly, const char *i_strMessage);
99: inline void SetMethod(LogMethod i_lm);
100: inline void SetPriority(LogPriority i_lyAll);
101: inline void SetPriority(LogFacility i_lf, LogPriority i_ly);
102: inline void SetStream(ostream *i_smp);
103: inline bool WouldLog(LogFacility i_lf, LogPriority i_ly);
104: ~MINDLog(void);
105:
106: protected:
107: inline int SyslogPri(LogPriority i_ly);
108:
109: protected:
110: LogMethod m_lm;
111: LogPriority *m_lya;
112: ostream *m_smp;
113: Mutex m_mx;
114: };
115: typedef MINDLog *MINDLogPtr;
116:
117:
118: /************************
119: * *
120: * FUNCTION PROTOTYPES *
121: * *
122: ************************/
123:
124:
125: inline void FastLog(LogFacility i_lf, LogPriority i_ly, const char *i_strMessage);
126:
127:
128: /*********************
129: * *
130: * INLINE FUNCTIONS *
131: * *
132: *********************/
133:
134:
135: #include "mindlog.i"
136:
137:
138: /************
139: * *
140: * THE END *
141: * *
142: ************/
143:
144:
145: #endif
146:
147:
148: