Skip to content
Snippets Groups Projects
Commit a5a91a2a authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Andreas Traczyk
Browse files

log: fix crash with DHT log


Commit [0eb462a8: change win32 logger for better readability]
has a regression with DHT logs causing crashes.

DHT logs don't have the '|' character in format string and
this was not checked by the incriminated commit.

Change-Id: Icffc89a2bf178292f183106f0139e0ded9535398
Reviewed-by: default avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 8ad7adfb
No related branches found
No related tags found
No related merge requests found
......@@ -201,10 +201,16 @@ vlogger(const int level, const char *format, va_list ap)
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);
std::string ctx;
// WARNING : the '|' exists only with ring logs, not other logs like thus from OpenDHT
// WARNING : PLEASE DO NOT DROP THIS TEST !!!! (or die)
auto sep = strchr(format, '|');
if (sep) {
ctx = std::string(format, sep - format);
format = sep + 2;
fputs(getHeader(ctx.c_str()).c_str(), stderr);
}
#ifdef RING_UWP
char tmp[4096];
vsprintf(tmp, format, ap);
......@@ -220,6 +226,10 @@ vlogger(const int level, const char *format, va_list ap)
vfprintf(stderr, format, ap);
// WARING: this one also! see above
if (not sep)
fputs(ENDL, stderr);
#ifndef _WIN32
fputs(END_COLOR, stderr);
#elif !defined(RING_UWP)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment