|
16 | 16 | #include "fmt/core.h" |
17 | 17 |
|
18 | 18 | #ifdef _WIN32 |
19 | | - #ifndef NOMINMAX |
20 | | - #define NOMINMAX |
21 | | - // Disable min/max macros in windows.h to avoid conflicts with std::min/max |
22 | | - // cxxopts.hpp uses std::min/max |
23 | | - #endif |
24 | | - |
25 | | - // Undefine Raylib functions to avoid conflicts |
26 | | - #define Rectangle WindowsRectangle |
27 | | - #define CloseWindow WindowsCloseWindow |
28 | | - #define ShowCursor WindowsShowCursor |
29 | | - #define DrawText WindowsDrawText |
30 | | - #define PlaySound WindowsPlaySound |
31 | | - #define PlaySoundA WindowsPlaySoundA |
32 | | - #define PlaySoundW WindowsPlaySoundW |
33 | | - #define LoadImage WindowsLoadImage |
34 | | - #define DrawTextEx WindowsDrawTextEx |
35 | | - |
36 | | - #include <windows.h> |
37 | | - |
38 | | - // Restore Raylib functions |
39 | | - #undef Rectangle |
40 | | - #undef CloseWindow |
41 | | - #undef ShowCursor |
42 | | - #undef DrawText |
43 | | - #undef PlaySound |
44 | | - #undef PlaySoundA |
45 | | - #undef PlaySoundW |
46 | | - #undef LoadImage |
47 | | - #undef DrawTextEx |
48 | | - |
| 19 | + #include "../WindowsHeaders.hpp" |
49 | 20 | #endif |
50 | 21 |
|
51 | 22 | class ConsoleLogger : public dotnamecpp::logging::ILogger { |
@@ -99,7 +70,8 @@ class ConsoleLogger : public dotnamecpp::logging::ILogger { |
99 | 70 | void critical (const std::string& message, const std::string& caller = "") override { |
100 | 71 | log (dotnamecpp::logging::Level::LOG_CRITICAL, message, caller); |
101 | 72 | }; |
102 | | - void log (dotnamecpp::logging::Level level, const std::string& message, const std::string& caller) { |
| 73 | + void log (dotnamecpp::logging::Level level, const std::string& message, |
| 74 | + const std::string& caller) { |
103 | 75 | // thread-safety |
104 | 76 | std::lock_guard<std::mutex> lock (logMutex_); |
105 | 77 |
|
@@ -202,13 +174,15 @@ class ConsoleLogger : public dotnamecpp::logging::ILogger { |
202 | 174 | } |
203 | 175 |
|
204 | 176 | #ifdef _WIN32 |
205 | | - static void setConsoleColorWindows (Level level) { |
206 | | - const std::map<Level, WORD> colorMap |
207 | | - = { { Level::LOG_DEBUG, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY }, |
208 | | - { Level::LOG_INFO, FOREGROUND_GREEN | FOREGROUND_INTENSITY }, |
209 | | - { Level::LOG_WARNING, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY }, |
210 | | - { Level::LOG_ERROR, FOREGROUND_RED | FOREGROUND_INTENSITY }, |
211 | | - { Level::LOG_CRITICAL, |
| 177 | + static void setConsoleColorWindows (dotnamecpp::logging::Level level) { |
| 178 | + const std::map<dotnamecpp::logging::Level, WORD> colorMap |
| 179 | + = { { dotnamecpp::logging::Level::LOG_DEBUG, |
| 180 | + FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY }, |
| 181 | + { dotnamecpp::logging::Level::LOG_INFO, FOREGROUND_GREEN | FOREGROUND_INTENSITY }, |
| 182 | + { dotnamecpp::logging::Level::LOG_WARNING, |
| 183 | + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY }, |
| 184 | + { dotnamecpp::logging::Level::LOG_ERROR, FOREGROUND_RED | FOREGROUND_INTENSITY }, |
| 185 | + { dotnamecpp::logging::Level::LOG_CRITICAL, |
212 | 186 | FOREGROUND_RED | FOREGROUND_INTENSITY | FOREGROUND_BLUE } }; |
213 | 187 | auto it = colorMap.find (level); |
214 | 188 | if (it != colorMap.end ()) { |
@@ -251,8 +225,8 @@ class ConsoleLogger : public dotnamecpp::logging::ILogger { |
251 | 225 | bool includeCaller_ = true; |
252 | 226 | bool includeLevel_ = true; |
253 | 227 |
|
254 | | - void logToStream (std::ostream& stream, dotnamecpp::logging::Level level, const std::string& message, |
255 | | - const std::string& caller, const std::tm& now_tm) { |
| 228 | + void logToStream (std::ostream& stream, dotnamecpp::logging::Level level, |
| 229 | + const std::string& message, const std::string& caller, const std::tm& now_tm) { |
256 | 230 | setConsoleColor (level); |
257 | 231 | stream << buildHeader (now_tm, caller, level) << message; |
258 | 232 | resetConsoleColor (); |
|
0 commit comments