1
0

Merge pull request #2420 from cuberite/FlushLog

Flush log file when a warning or error message is output.
This commit is contained in:
Julian Laubstein 2015-08-08 11:15:48 +02:00
commit 171e754a6e

View File

@ -317,6 +317,7 @@ cFileListener::cFileListener(void)
void cFileListener::Log(AString a_Message, cLogger::eLogLevel a_LogLevel)
{
const char * LogLevelPrefix = "Unkn ";
bool ShouldFlush = false;
switch (a_LogLevel)
{
case cLogger::llRegular:
@ -332,15 +333,21 @@ void cFileListener::Log(AString a_Message, cLogger::eLogLevel a_LogLevel)
case cLogger::llWarning:
{
LogLevelPrefix = "Warn ";
ShouldFlush = true;
break;
}
case cLogger::llError:
{
LogLevelPrefix = "Err ";
ShouldFlush = true;
break;
}
}
m_File.Printf("%s%s", LogLevelPrefix, a_Message.c_str());
if (ShouldFlush)
{
m_File.Flush();
}
}