DefaultLogger: fix missing sprintf calls.

pull/749/head
Kim Kulling 2016-01-03 23:29:37 +01:00
parent d26187714d
commit 847644ca75
1 changed files with 13 additions and 10 deletions

View File

@ -226,9 +226,7 @@ bool DefaultLogger::isNullLogger()
} }
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
// Singleton getter Logger *DefaultLogger::get() {
Logger *DefaultLogger::get()
{
return m_pLogger; return m_pLogger;
} }
@ -241,7 +239,9 @@ void DefaultLogger::kill()
boost::mutex::scoped_lock lock(loggerMutex); boost::mutex::scoped_lock lock(loggerMutex);
#endif #endif
if (m_pLogger == &s_pNullLogger)return; if ( m_pLogger == &s_pNullLogger ) {
return;
}
delete m_pLogger; delete m_pLogger;
m_pLogger = &s_pNullLogger; m_pLogger = &s_pNullLogger;
} }
@ -253,8 +253,9 @@ void DefaultLogger::OnDebug( const char* message )
if ( m_Severity == Logger::NORMAL ) if ( m_Severity == Logger::NORMAL )
return; return;
char msg[MAX_LOG_MESSAGE_LENGTH + 16]; static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16;
::sprintf(msg,"Debug, T%u: %s", GetThreadID(), message ); char msg[Size];
::snprintf(msg, Size-1, "Debug, T%u: %s", GetThreadID(), message);
WriteToStreams( msg, Logger::Debugging ); WriteToStreams( msg, Logger::Debugging );
} }
@ -263,8 +264,9 @@ void DefaultLogger::OnDebug( const char* message )
// Logs an info // Logs an info
void DefaultLogger::OnInfo( const char* message ) void DefaultLogger::OnInfo( const char* message )
{ {
char msg[MAX_LOG_MESSAGE_LENGTH + 16]; static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16;
::sprintf(msg,"Info, T%u: %s", GetThreadID(), message ); char msg[Size];
::snprintf(msg, Size-1, "Info, T%u: %s", GetThreadID(), message );
WriteToStreams( msg , Logger::Info ); WriteToStreams( msg , Logger::Info );
} }
@ -273,8 +275,9 @@ void DefaultLogger::OnInfo( const char* message )
// Logs a warning // Logs a warning
void DefaultLogger::OnWarn( const char* message ) void DefaultLogger::OnWarn( const char* message )
{ {
char msg[MAX_LOG_MESSAGE_LENGTH + 16]; static const size_t Size = MAX_LOG_MESSAGE_LENGTH + 16;
::sprintf(msg,"Warn, T%u: %s", GetThreadID(), message ); char msg[Size];
::snprintf(msg, Size - 1, "Warn, T%u: %s", GetThreadID(), message );
WriteToStreams( msg, Logger::Warn ); WriteToStreams( msg, Logger::Warn );
} }