| 177 | |
| 178 | |
| 179 | void cMCLogger::SetColor(eColorScheme a_Scheme) |
| 180 | { |
| 181 | if (!g_ShouldColorOutput) |
| 182 | { |
| 183 | return; |
| 184 | } |
| 185 | #ifdef _WIN32 |
| 186 | WORD Attrib = 0x07; // by default, gray on black |
| 187 | switch (a_Scheme) |
| 188 | { |
| 189 | case csRegular: Attrib = 0x07; break; // Gray on black |
| 190 | case csInfo: Attrib = 0x0e; break; // Yellow on black |
| 191 | case csWarning: Attrib = 0x0c; break; // Read on black |
| 192 | case csError: Attrib = 0xc0; break; // Black on red |
| 193 | default: ASSERT(!"Unhandled color scheme"); |
| 194 | } |
| 195 | SetConsoleTextAttribute(g_Console, Attrib); |
| 196 | #elif defined(__linux) && !defined(ANDROID_NDK) |
| 197 | switch (a_Scheme) |
| 198 | { |
| 199 | case csRegular: printf("\x1b[0m"); break; // Whatever the console default is |
| 200 | case csInfo: printf("\x1b[33;1m"); break; // Yellow on black |
| 201 | case csWarning: printf("\x1b[31;1m"); break; // Red on black |
| 202 | case csError: printf("\x1b[1;33;41;1m"); break; // Yellow on red |
| 203 | default: ASSERT(!"Unhandled color scheme"); |
| 204 | } |
| 205 | #endif |
| 206 | } |
| 207 | |
| 208 | |
| 209 | |