-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebug.cpp
More file actions
63 lines (51 loc) · 1.83 KB
/
Debug.cpp
File metadata and controls
63 lines (51 loc) · 1.83 KB
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
#include "Debug.h"
HANDLE Debug::handle = GetStdHandle(STD_OUTPUT_HANDLE);
Window* Debug::_window = nullptr;
void Debug::Initialize(Window* window)
{
_window = window;
}
void Debug::Log(const std::string& message)
{
DisplayLog(LOG_PREFIX, message, ConsoleColor::WHITE);
}
void Debug::Log(const std::string& message, const std::string& from)
{
DisplayLog(LOG_PREFIX, message, from, ConsoleColor::WHITE);
}
void Debug::LogInfo(const std::string& message)
{
DisplayLog(LOG_INFO_PREFIX, message, ConsoleColor::CYAN);
}
void Debug::LogInfo(const std::string& message, const std::string& from)
{
DisplayLog(LOG_INFO_PREFIX, message, from, ConsoleColor::CYAN);
}
void Debug::LogWarning(const std::string& message)
{
DisplayLog(LOG_WARNING_PREFIX, message, ConsoleColor::YELLOW);
}
void Debug::LogWarning(const std::string& message, const std::string& from)
{
DisplayLog(LOG_WARNING_PREFIX, message, from, ConsoleColor::YELLOW);
}
void Debug::LogError(const std::string& message)
{
DisplayLog(LOG_ERROR_PREFIX, message, ConsoleColor::RED);
}
void Debug::LogError(const std::string& message, const std::string& from)
{
DisplayLog(LOG_ERROR_PREFIX, message, from, ConsoleColor::RED);
}
void Debug::DisplayLog(const std::string& prefix, const std::string& message, ConsoleColor color)
{
SetConsoleTextAttribute(handle, (int)color);
std::cout << prefix << ": " << message << "\n";
SetConsoleTextAttribute(handle, (int)ConsoleColor::WHITE);
}
void Debug::DisplayLog(const std::string& prefix, const std::string& message, const std::string& from, ConsoleColor color)
{
SetConsoleTextAttribute(handle, (int)color);
std::cout << std::setiosflags(std::ios::left) << std::setw(DEBUG_LEFT_SIZE) << from << std::setiosflags(std::ios::left) << std::setw(DEBUG_TYPE_SIZE) << prefix << ": " << message << "\n";
SetConsoleTextAttribute(handle, (int)ConsoleColor::WHITE);
}