aboutsummaryrefslogtreecommitdiffstats
path: root/debug.h
blob: 919eea47aa6e9d4903c0dce8a6f02004eed28f0b (plain) (blame)
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
#ifndef __RB_DEBUG_UTILS_H
#define __RB_DEBUG_UTILS_H

//what about kprintf?

//config options
#define PRINTF printf
#define COLORIZE
#define PRINT_LINENUM
#define PRINT_FILENAME
#define PRINT_DEBUG


//use color
#ifdef COLORIZE
	#define D_COLOR "1;32m"
	#define D_COLOR_S "\033[" D_COLOR
	#define D_COLOR_E "\033[0m"
	#define E_COLOR "1;31m"
	#define E_COLOR_S "\033[" E_COLOR
	#define E_COLOR_E "\033[0m"
	#define W_COLOR "1;35m"
	#define W_COLOR_S "\033[" W_COLOR
	#define W_COLOR_E "\033[0m"
	#define PE_COLOR "1;33m"
	#define PE_COLOR_S "\033[" PE_COLOR
	#define PE_COLOR_E "\033[0m"
#else
	#define D_COLOR
	#define D_COLOR_S
	#define D_COLOR_E
	#define E_COLOR
	#define E_COLOR_S
	#define E_COLOR_E
	#define W_COLOR
	#define W_COLOR_S
	#define W_COLOR_E
	#define PE_COLOR
	#define PE_COLOR_S
	#define PE_COLOR_E
#endif

//print debug line
#ifdef PRINT_LINENUM
	#define PRINT_LINE_F "LINE:%d "
	#define PRINT_LINE_D __LINE__
#else
	#define PRINT_LINE_F ""
	#define PRINT_LINE_D ""
#endif

//print
#ifdef PRINT_FILENAME
	#define PRINT_FILE_F "FILE:%s "
	#define PRINT_FILE_D __FILE__
#else
	#define PRINT_FILE_F ""
	#define PRINT_FILE_D ""
#endif

//print debug string
#ifdef PRINT_DEBUG
	#define PRINT_DEBUG_F "Debug: "
	#define PRINT_WARNING_F "WARN: "
	#define PRINT_PERROR_F "PRME: "
#else
	#define PRINT_DEBUG_F ""
	#define PRINT_WARNING_F ""
	#define PRINT_PERROR_F ""
#endif

#define PRINT( format, args ... ) PRINTF( D_COLOR_S PRINT_DEBUG_F \
	PRINT_FILE_F PRINT_LINE_F format D_COLOR_E, PRINT_FILE_D, \
	PRINT_LINE_D, ##args);

#define ERROR( format, args ... ) PRINTF( E_COLOR_S PRINT_DEBUG_F \
	PRINT_FILE_F PRINT_LINE_F format E_COLOR_E, PRINT_FILE_D, \
	PRINT_LINE_D, ##args);

#define WARNING( format, args ... ) PRINTF( W_COLOR_S PRINT_WARNING_F \
	PRINT_FILE_F PRINT_LINE_F format W_COLOR_E, PRINT_FILE_D, \
	PRINT_LINE_D, ##args);

#define PERROR( format, args ... ) PRINTF( PE_COLOR_S PRINT_WARNING_F \
	PRINT_FILE_F PRINT_LINE_F format PE_COLOR_E, PRINT_FILE_D, \
	PRINT_LINE_D, ##args);

#define PNL() PRINT("\n");

#define ENL() ERROR("\n");

#define WRN() WARNING("\n");

#define PERM() PERROR("\n");

/*ERROR LEVEL TYPES*/


#endif