Rev 10 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#include "log.h"
CLog *CLog::m_pInstance = 0;
CLog::CLog()
{
}
CLog::~CLog()
{
}
CLog *CLog::create()
{
if ( !m_pInstance ) {
m_pInstance = new CLog();
}
return m_pInstance;
}
void CLog::release()
{
if ( m_pInstance ) {
delete m_pInstance;
}
m_pInstance = 0;
}
void CLog::log(int iLevel, const Utils::String &sLogText)
{
CLog *pLogger = CLog::create();
pLogger->_log(iLevel, sLogText);
}
void CLog::displayLog(int iLevel, const Utils::String &sLogText) const
{
}
void CLog::_log(int iLevel, const Utils::String &sLogText)
{
SLog *newLog = new SLog;
newLog->sText = sLogText;
newLog->iLevel = iLevel;
m_lLogs.push_back(newLog);
this->displayLog(iLevel, sLogText);
}
void CLog::logf(int iLevel, const char *sLogText, ...)
{
char buffer[10000];
va_list args;
va_start (args, sLogText);
vsprintf (buffer, sLogText, args);
va_end (args);
CLog::log(iLevel, buffer);
}
void CLog::_logf(int iLevel, const char *sLogText, ...)
{
char buffer[10000];
va_list args;
va_start (args, sLogText);
vsprintf (buffer, sLogText, args);
va_end (args);
this->_log(iLevel, buffer);
}
void CLog::clear()
{
m_lLogs.clear(true);
}
const SLog *CLog::firstLog() const
{
if ( !m_lLogs.Front() ) return NULL;
return m_lLogs.Front()->Data();
}
int CLog::count() const
{
return m_lLogs.size();
}