Skip to content
Snippets Groups Projects
Commit 38c9874b authored by Adrien Béraud's avatar Adrien Béraud
Browse files

log: fix logging for dht

Change-Id: Icb99fb59e51f47b7dfb269a642c08e4f6575a845
Tuleap: #708
parent bea0a9b9
No related branches found
No related tags found
No related merge requests found
......@@ -153,28 +153,37 @@ vlogger(const int level, const char *format, va_list ap)
break;
}
#ifndef _WIN32
fputs(color_header, stderr);
#else
#ifdef _WIN32
GetConsoleScreenBufferInfo(hConsole, &consoleInfo);
saved_attributes = consoleInfo.wAttributes;
SetConsoleTextAttribute(hConsole, color_header);
#endif
auto sep = strchr(format, '|'); // must exist, check LOG_FORMAT
std::string ctx(format, sep - format);
format = sep + 2;
fputs(getHeader(ctx.c_str()).c_str(), stderr);
// must exist, check LOG_FORMAT
auto sep = strchr(format, '|');
if (sep) {
#ifndef _WIN32
fputs(color_header, stderr);
#else
SetConsoleTextAttribute(hConsole, color_header);
#endif
std::string ctx(format, sep - format);
format = sep + 2;
fputs(getHeader(ctx.c_str()).c_str(), stderr);
#ifndef _WIN32
fputs(END_COLOR, stderr);
#else
SetConsoleTextAttribute(hConsole, saved_attributes);
#endif
}
#ifndef _WIN32
fputs(END_COLOR, stderr);
fputs(color_prefix, stderr);
#else
SetConsoleTextAttribute(hConsole, saved_attributes);
SetConsoleTextAttribute(hConsole, color_prefix);
#endif
vfprintf(stderr, format, ap);
if (not sep)
fputs(ENDL, stderr);
#ifndef _WIN32
fputs(END_COLOR, stderr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment