-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.cpp
130 lines (124 loc) · 3.11 KB
/
debug.cpp
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
#include "include/common.h"
//Print the string with color.
int log_str(char* str,STR_COLOR color,int tab_level)
{
if(tab_level)print_tab(tab_level);
switch (color){
case RED_STR:
printf(RED "%s" COLOR_NONE,str);
break;
case BLUE_STR:
printf(BLUE "%s" COLOR_NONE,str);
break;
case GREEN_STR:
printf(GREEN "%s" COLOR_NONE,str);
break;
case YELLOW_STR:
printf(YELLOW "%s" COLOR_NONE,str);
break;
case NONE_STR:
printf("%s",str);
break;
default:
break;
}
printf("\n");
return 0;
}
int log_str(char* str1,char* str2,STR_COLOR color,int tab_level)
{
if(tab_level)print_tab(tab_level);
switch (color){
case RED_STR:
printf(RED "%s %s" COLOR_NONE,str1,str2);
break;
case BLUE_STR:
printf(BLUE "%s %s" COLOR_NONE,str1,str2);
break;
case GREEN_STR:
printf(GREEN "%s %s" COLOR_NONE,str1,str2);
break;
case YELLOW_STR:
printf(YELLOW "%s %s" COLOR_NONE,str1,str2);
break;
case NONE_STR:
printf("%s %s",str1,str2);
break;
default:
break;
}
printf("\n");
return 0;
}
int log_str(int str,STR_COLOR color,int tab_level)
{
if(tab_level)print_tab(tab_level);
switch (color){
case RED_STR:
printf(RED "%d" COLOR_NONE,str);
break;
case BLUE_STR:
printf(BLUE "%d" COLOR_NONE,str);
break;
case GREEN_STR:
printf(GREEN "%d" COLOR_NONE,str);
break;
case YELLOW_STR:
printf(YELLOW "%d" COLOR_NONE,str);
break;
case NONE_STR:
printf("%d",str);
break;
default:
break;
}
printf("\n");
return 0;
}
int log_str(char str,STR_COLOR color,int tab_level)
{
if(tab_level)print_tab(tab_level);
switch (color){
case RED_STR:
printf(RED "%c" COLOR_NONE,str);
break;
case BLUE_STR:
printf(BLUE "%c" COLOR_NONE,str);
break;
case GREEN_STR:
printf(GREEN "%c" COLOR_NONE,str);
break;
case YELLOW_STR:
printf(YELLOW "%c" COLOR_NONE,str);
break;
case NONE_STR:
printf("%c",str);
break;
default:
break;
}
printf("\n");
return 0;
}
int log_error(char* str,int tab_level){
return log_str(str,RED_STR,tab_level);
}
int log_error(char* str1,char* str2,int tab_level){
return log_str(str1,str2,RED_STR,tab_level);
}
int log_info(char* str,int tab_level){
return log_str(str,BLUE_STR,tab_level);
}
int log_info(char* str1,char* str2,int tab_level){
return log_str(str1,str2,BLUE_STR,tab_level);
}
int log_stone(int i){
char str[10];
sprintf(str,"%d",i);
log_error(str);
}
int print_tab(int tab_level){
for(int i=0;i<tab_level;i++){
std::cout<<"\t";
}
}