Subversion Repositories spk

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
#include "log.h"
2
 
3
CLog *CLog::m_pInstance = 0;
4
 
5
CLog::CLog()
6
{
7
}
8
 
9
CLog::~CLog()
10
{
11
}
12
 
13
CLog *CLog::create()
14
{
15
	if ( !m_pInstance ) {
16
		m_pInstance = new CLog();
17
	}
18
	return m_pInstance;
19
}
20
 
21
void CLog::release()
22
{
23
	if ( m_pInstance ) {
24
		delete m_pInstance;
25
	}
26
	m_pInstance = 0;
27
}
28
 
29
void CLog::log(const CyString &sLogText)
30
{
31
	CLog *pLogger = CLog::create();
32
	pLogger->_log(sLogText);
33
}
34
 
7 cycrow 35
void CLog::displayLog(const CyString &sLogText) const
36
{
37
}
38
 
1 cycrow 39
void CLog::_log(const CyString &sLogText)
40
{
7 cycrow 41
	SLog *log = new SLog;
42
	log->sText = sLogText;
43
	m_lLogs.push_back(log);
44
 
45
	this->displayLog(sLogText);
46
}
47
 
48
void CLog::logf(const char *sLogText, ...)
49
{
50
	char buffer[10000];
51
	va_list args;
52
	va_start (args, sLogText);
53
	vsprintf (buffer, sLogText, args);
54
	va_end (args);
55
 
56
	CLog::log(buffer);
57
}
58
void CLog::_logf(const char *sLogText, ...)
59
{
60
	char buffer[10000];
61
	va_list args;
62
	va_start (args, sLogText);
63
	vsprintf (buffer, sLogText, args);
64
	va_end (args);
65
 
66
	this->_log(buffer);
67
}
68
 
69
void CLog::clear()
70
{
71
	for ( LogListItr itr = m_lLogs.begin(); itr != m_lLogs.end(); ++itr ) {
72
		delete *itr;
73
	}
74
	m_lLogs.clear();
75
}
76
 
77
SLog *CLog::firstLog()
78
{
79
	LogList::iterator itr = m_lLogs.begin();
80
	if ( itr != m_lLogs.end() ) return *itr;
81
	return NULL;
82
}