Skip to content

Commit

Permalink
Refactor log function.
Browse files Browse the repository at this point in the history
Slight reorganization to allow for variable reuse and elimination.
  • Loading branch information
althekiller committed Feb 10, 2011
1 parent 215814a commit d224a8b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions xbmc/utils/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ void CLog::Log(int loglevel, const char *format, ... )

CStdString strPrefix, strData;

strPrefix.Format(prefixFormat, time.wHour, time.wMinute, time.wSecond, (uint64_t)CThread::GetCurrentThreadId(), (uint64_t)stat.dwAvailPhys, levelNames[loglevel]);

strData.reserve(16384);
va_list va;
va_start(va, format);
Expand All @@ -94,12 +92,12 @@ void CLog::Log(int loglevel, const char *format, ... )
}
else if (m_repeatCount)
{
CStdString strPrefix2, strData2;
strPrefix2.Format(prefixFormat, time.wHour, time.wMinute, time.wSecond, (uint64_t)CThread::GetCurrentThreadId(), (uint64_t)stat.dwAvailPhys, levelNames[m_repeatLogLevel]);
CStdString strData2;
strPrefix.Format(prefixFormat, time.wHour, time.wMinute, time.wSecond, (uint64_t)CThread::GetCurrentThreadId(), (uint64_t)stat.dwAvailPhys, levelNames[m_repeatLogLevel]);

strData2.Format("Previous line repeats %d times." LINE_ENDING, m_repeatCount);
OutputDebugString(strData2);
fputs(strPrefix2.c_str(), m_file);
fputs(strPrefix.c_str(), m_file);
fputs(strData2.c_str(), m_file);
m_repeatCount = 0;
}
Expand All @@ -125,6 +123,8 @@ void CLog::Log(int loglevel, const char *format, ... )
strData.Replace("\n", LINE_ENDING" ");
strData += LINE_ENDING;

strPrefix.Format(prefixFormat, time.wHour, time.wMinute, time.wSecond, (uint64_t)CThread::GetCurrentThreadId(), (uint64_t)stat.dwAvailPhys, levelNames[loglevel]);

fputs(strPrefix.c_str(), m_file);
fputs(strData.c_str(), m_file);
fflush(m_file);
Expand Down

0 comments on commit d224a8b

Please sign in to comment.