Rev 1 | Rev 8 | Go to most recent revision | 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(const CyString &sLogText)
{
CLog *pLogger = CLog::create();
pLogger->_log(sLogText);
}
void CLog::displayLog(const CyString &sLogText) const
{
}
void CLog::_log(const CyString &sLogText)
{
SLog *log = new SLog;
log->sText = sLogText;
m_lLogs.push_back(log);
this->displayLog(sLogText);
}
void CLog::logf(const char *sLogText, ...)
{
char buffer[10000];
va_list args;
va_start (args, sLogText);
vsprintf (buffer, sLogText, args);
va_end (args);
CLog::log(buffer);
}
void CLog::_logf(const char *sLogText, ...)
{
char buffer[10000];
va_list args;
va_start (args, sLogText);
vsprintf (buffer, sLogText, args);
va_end (args);
this->_log(buffer);
}
void CLog::clear()
{
for ( LogListItr itr = m_lLogs.begin(); itr != m_lLogs.end(); ++itr ) {
delete *itr;
}
m_lLogs.clear();
}
SLog *CLog::firstLog()
{
LogList::iterator itr = m_lLogs.begin();
if ( itr != m_lLogs.end() ) return *itr;
return NULL;
}