-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdebug.cc
165 lines (134 loc) · 5.05 KB
/
debug.cc
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
# Copyright 2021, qnx-audi - https://github.com/h4570/qnx-audi
# Licenced under Apache License 2.0
# Sandro Sobczyński <[email protected]>
*/
#include "utils/debug.hh"
#ifdef NDEBUG
// ----
// Release mode, all
// ----
#ifdef TARGET_PC
// ----
// Release mode, x86
// ----
void Debug::_assert(const bool &t_condition, const char *t_message, const char *t_file, const int &t_line) {}
void Debug::_log(const char *t_message, const char *t_file, const int &t_line) {}
void Debug::_log(const char *t_key, const int t_value, const char *t_file, const int &t_line) {}
void Debug::_log(const char *t_key, const unsigned int t_value, const char *t_file, const int &t_line) {}
void Debug::_log(const char *t_key, const bool t_value, const char *t_file, const int &t_line) {}
void Debug::_log(const char *t_key, const char *t_value, const char *t_file, const int &t_line) {}
#else // TARGET_PC
// ----
// Release mode, SHLE
// ----
void Debug::_assert(const bool &t_condition, const char *t_message, const char *t_file, const int &t_line) {}
void Debug::_log(const char *t_message, const char *t_file, const int &t_line) {}
void Debug::_log(const char *t_key, const int t_value, const char *t_file, const int &t_line) {}
void Debug::_log(const char *t_key, const unsigned int t_value, const char *t_file, const int &t_line) {}
void Debug::_log(const char *t_key, const bool t_value, const char *t_file, const int &t_line) {}
void Debug::_log(const char *t_key, const char *t_value, const char *t_file, const int &t_line) {}
#endif // TARGET_PC
#else // NDEBUG
// ----
// Debug mode, all
// ----
#include <stdlib.h>
#include <stdio.h>
#include <GLES/gl.h>
void Debug::_checkOpenGLError(const char *t_statement, const char *t_name, const int &t_line)
{
GLenum err = glGetError();
if (err != GL_NO_ERROR)
{
printf("OpenGL error %08x, at %s:%i - for %s\n", err, t_name, t_line, t_statement);
exit(1);
}
}
#ifdef TARGET_PC
// ----
// Debug mode, x86
// ----
void Debug::_assert(const bool &t_condition, const char *t_message, const char *t_file, const int &t_line)
{
if (!t_condition)
{
fprintf(stdout, "Assertion failed: %s | %s:%d\n", t_message, t_file, t_line);
fprintf(stderr, "Assertion failed: %s | %s:%d\n", t_message, t_file, t_line);
exit(1);
}
}
void Debug::_log(const char *t_message, const char *t_file, const int &t_line)
{
fprintf(stdout, "Log: %s | %s:%d\n", t_message, t_file, t_line);
}
void Debug::_log(const char *t_key, const int t_value, const char *t_file, const int &t_line)
{
fprintf(stdout, "Log: %s = %d | %s:%d\n", t_key, t_value, t_file, t_line);
}
void Debug::_log(const char *t_key, const unsigned int t_value, const char *t_file, const int &t_line)
{
fprintf(stdout, "Log: %s = %d | %s:%d\n", t_key, t_value, t_file, t_line);
}
void Debug::_log(const char *t_key, const bool t_value, const char *t_file, const int &t_line)
{
fprintf(stdout, "Log: %s = %d | %s:%d\n", t_key, t_value, t_file, t_line);
}
void Debug::_log(const char *t_key, const char *t_value, const char *t_file, const int &t_line)
{
fprintf(stdout, "Log: %s = %s | %s:%d\n", t_key, t_value, t_file, t_line);
}
#else // TARGET_PC
// ----
// Debug mode, SHLE
// ----
#include <fstream>
#include "config.hh"
void Debug::_assert(const bool &t_condition, const char *t_message, const char *t_file, const int &t_line)
{
if (!t_condition)
{
std::ofstream myfile;
myfile.open(AUDI_LOGS_FILE, std::ios_base::app);
myfile << "Assertion failed: " << t_message << " | " << t_file << ":" << t_line << "\n";
myfile.close();
exit(1);
}
}
void Debug::_log(const char *t_message, const char *t_file, const int &t_line)
{
std::ofstream myfile;
myfile.open(AUDI_LOGS_FILE, std::ios_base::app);
myfile << "Log: " << t_message << " | " << t_file << ":" << t_line << "\n";
myfile.close();
}
void Debug::_log(const char *t_key, const int t_value, const char *t_file, const int &t_line)
{
std::ofstream myfile;
myfile.open(AUDI_LOGS_FILE, std::ios_base::app);
myfile << "Log: " << t_key << " = " << t_value << " | " << t_file << ":" << t_line << "\n";
myfile.close();
}
void Debug::_log(const char *t_key, const unsigned int t_value, const char *t_file, const int &t_line)
{
std::ofstream myfile;
myfile.open(AUDI_LOGS_FILE, std::ios_base::app);
myfile << "Log: " << t_key << " = " << t_value << " | " << t_file << ":" << t_line << "\n";
myfile.close();
}
void Debug::_log(const char *t_key, const bool t_value, const char *t_file, const int &t_line)
{
std::ofstream myfile;
myfile.open(AUDI_LOGS_FILE, std::ios_base::app);
myfile << "Log: " << t_key << " = " << t_value << " | " << t_file << ":" << t_line << "\n";
myfile.close();
}
void Debug::_log(const char *t_key, const char *t_value, const char *t_file, const int &t_line)
{
std::ofstream myfile;
myfile.open(AUDI_LOGS_FILE, std::ios_base::app);
myfile << "Log: " << t_key << " = " << t_value << " | " << t_file << ":" << t_line << "\n";
myfile.close();
}
#endif // TARGET_PC
#endif // NDEBUG