Some tidy up of sprintf to StringFromFormat

This commit is contained in:
Matthew Parlane 2014-02-08 14:23:34 +13:00
parent 64e01ec763
commit ebff7974c3
13 changed files with 64 additions and 111 deletions

View file

@ -114,7 +114,6 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
const char *file, int line, const char *format, va_list args)
{
char temp[MAX_MSGLEN];
char msg[MAX_MSGLEN * 2];
LogContainer *log = m_Log[type];
if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners())
@ -122,15 +121,15 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
CharArrayFromFormatV(temp, MAX_MSGLEN, format, args);
static const char level_to_char[7] = "-NEWID";
sprintf(msg, "%s %s:%u %c[%s]: %s\n",
Common::Timer::GetTimeFormatted().c_str(),
file, line, level_to_char[(int)level],
log->GetShortName(), temp);
std::string msg = StringFromFormat("%s %s:%u %c[%s]: %s\n",
Common::Timer::GetTimeFormatted().c_str(),
file, line,
LogTypes::LOG_LEVEL_TO_CHAR[(int)level],
log->GetShortName(), temp);
#ifdef ANDROID
Host_SysMessage(msg);
Host_SysMessage(msg.c_str());
#endif
log->Trigger(level, msg);
log->Trigger(level, msg.c_str());
}
void LogManager::Init()