-
Notifications
You must be signed in to change notification settings - Fork 15
/
Trace.h
65 lines (54 loc) · 1.9 KB
/
Trace.h
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
/*
*
* (C) 2021-24 - ntop.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef _TRACE_H_
#define _TRACE_H_
#define TRACE_LEVEL_ERROR 0
#define TRACE_LEVEL_WARNING 1
#define TRACE_LEVEL_NORMAL 2
#define TRACE_LEVEL_INFO 3
#define TRACE_LEVEL_DEBUG 6
#define TRACE_LEVEL_TRACE 9
#define TRACE_ERROR TRACE_LEVEL_ERROR, __FILE__, __LINE__
#define TRACE_WARNING TRACE_LEVEL_WARNING, __FILE__, __LINE__
#define TRACE_NORMAL TRACE_LEVEL_NORMAL, __FILE__, __LINE__
#define TRACE_INFO TRACE_LEVEL_INFO, __FILE__, __LINE__
#define TRACE_DEBUG TRACE_LEVEL_DEBUG, __FILE__, __LINE__
#define TRACE_TRACE TRACE_LEVEL_TRACE, __FILE__, __LINE__
#define MAX_TRACE_LEVEL 9
#define TRACE_DEBUGGING MAX_TRACE_LEVEL
/* ******************************* */
class Trace {
private:
u_int8_t traceLevel;
bool syslogOnly;
#ifdef WIN32
VOID AddToMessageLog(LPTSTR lpszMsg);
#endif
public:
Trace();
~Trace();
void init();
void set_trace_level(u_int8_t id);
inline u_int8_t get_trace_level() { return(traceLevel); };
void traceEvent(int eventTraceLevel, const char* file, const int line, const char * format, ...);
void traceToSyslogOnly() { syslogOnly = true; }
};
extern Trace *trace;
#endif /* _TRACE_H_ */