-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebuger.h
83 lines (62 loc) · 1.3 KB
/
Debuger.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* -- $Id: Debuger.h,v 1.12 2004/04/30 03:20:20 qianjinqi Exp $ -- */
#ifndef _DEBUGER_H_
#define _DEBUGER_H_
// FIXME #define _DEBUG_
#ifdef _DEBUG_
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
//#define NULL 0x00000000L
class CDebuger
{
private:
static CDebuger *pDebuger;
int m_debug_level;
public:
CDebuger();
~CDebuger();
static CDebuger *Instance();
int GetDebugLevel();
void SetDebugLevel(int);
};
#define TRACE(level, info){ \
CDebuger *pd = CDebuger::Instance(); \
int g_debug_level = pd->GetDebugLevel(); \
time_t g_t; \
g_t = time(NULL); \
if(g_debug_level >= level){ \
printf("\nProcess %d on %s:%d@%s ---- ", getpid(), ctime(&g_t), __LINE__, __FILE__); \
printf info; \
fflush(stdout); \
} \
}
#define PRINT(level, info){ \
CDebuger *pd = CDebuger::Instance(); \
int g_debug_level = pd->GetDebugLevel(); \
if(g_debug_level >= level){ \
printf info; \
fflush(stdout); \
} \
}
#define OUTPUT(info){ \
time_t g_t; \
g_t = time(NULL); \
printf("\nProcess %d on %s:%d@%s ---- ", getpid(), ctime(&g_t), __LINE__, __FILE__); \
printf info; \
fflush(stdout); \
}
#else
extern int g_debug_level;
#define TRACE(level, info){ \
printf info; \
printf("\n");\
}
#define PRINT(level, info){ \
; \
}
#define OUPUT( info){ \
; \
}
#endif
#endif