-
Notifications
You must be signed in to change notification settings - Fork 3
/
debug.cpp
43 lines (34 loc) · 1.15 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
#include "weblegends.h"
#ifdef WEBLEGENDS_DEBUG
#include "weblegends-git-describe.h"
#include <iostream>
static std::ofstream weblegends_debug_stream;
static void weblegends_debug_log_message()
{
auto & console = Core::getInstance().getConsole();
console << COLOR_YELLOW;
console << "[weblegends] Debug messages have been written "
"to weblegends_debug.log. Please send this file to "
"https://github.com/BenLubar/weblegends" << std::endl;
console << COLOR_RESET;
}
std::ostream & weblegends_debug_log()
{
if (!weblegends_debug_stream.is_open())
{
weblegends_debug_stream.open("weblegends_debug.log", std::ios_base::out | std::ios_base::app);
weblegends_debug_stream << "weblegends " << WEBLEGENDS_GIT_DESCRIPTION << " debug log opened" << std::endl;
weblegends_debug_stream << "weblegends commit: " << WEBLEGENDS_GIT_COMMIT << std::endl;
weblegends_debug_log_message();
}
return weblegends_debug_stream;
}
void weblegends_debug_close_log()
{
if (!weblegends_debug_stream.is_open())
{
weblegends_debug_stream.close();
weblegends_debug_log_message();
}
}
#endif