Fix va_list clobbering

Adjust FileLogger output to match ConsoleLogger output
This commit is contained in:
Phillip Stephens 2016-01-04 18:42:43 -08:00
parent e7478c5bb4
commit 448c56e37b
2 changed files with 18 additions and 7 deletions

View File

@ -146,7 +146,12 @@ public:
inline void report(Level severity, const CharType* format, va_list ap)
{
for (auto& logger : MainLoggers)
logger->report(m_modName, severity, format, ap);
{
va_list apc;
va_copy(apc, ap);
logger->report(m_modName, severity, format, apc);
va_end(apc);
}
if (severity == Error || severity == FatalError)
LogVisorBp();
if (severity == FatalError)
@ -175,7 +180,13 @@ public:
inline void reportSource(Level severity, const char* file, unsigned linenum, const CharType* format, va_list ap)
{
for (auto& logger : MainLoggers)
logger->reportSource(m_modName, severity, file, linenum, format, ap);
{
va_list apc;
va_copy(apc, ap);
logger->reportSource(m_modName, severity, file, linenum, format, apc);
va_end(apc);
}
if (severity == FatalError)
abort();
else if (severity == Error)

View File

@ -332,6 +332,10 @@ struct FileLogger : public ILogger
thrName = ThreadMap[thrId];
fprintf(fp, "[");
fprintf(fp, "%5.4f ", tmd);
uint_fast64_t fIdx = FrameIndex.load();
if (fIdx)
fprintf(fp, "(%" PRIu64 ") ", fIdx);
switch (severity)
{
case Info:
@ -351,13 +355,9 @@ struct FileLogger : public ILogger
};
fprintf(fp, " %s", modName);
if (sourceInfo)
fprintf(stderr, " {%s}", sourceInfo);
fprintf(fp, " {%s}", sourceInfo);
if (thrName)
fprintf(fp, " (%s)", thrName);
fprintf(fp, " %5.4f", tmd);
uint_fast64_t fIdx = FrameIndex.load();
if (fIdx)
fprintf(fp, " (%" PRIu64 ")", fIdx);
fprintf(fp, "] ");
}