PageRenderTime 23ms CodeModel.GetById 18ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/TGame/TUtil/Sqlite/Log_SQLite.cpp

http://awoe.googlecode.com/
C++ | 60 lines | 42 code | 6 blank | 12 comment | 4 complexity | ee5e5b43bb65396c11ae70175d2dbe49 MD5 | raw file
 1
 2#include "stdafx.h"
 3#include "Log_SQLite.h"
 4#include <fstream>
 5#include <time.h>
 6
 7
 8Log_SQLite::Log_SQLite(void)
 9{
10}
11
12Log_SQLite::~Log_SQLite(void)
13{
14}
15
16//std::auto_ptr<CString> Log_SQLite::GetDayTime()
17//{
18//	std::auto_ptr<CString> strDT(new CString("["));
19//	TCHAR buffer[9];
20//	_tstrdate_s(buffer,9);
21//	strDT->Append(buffer);
22//	_tstrtime_s(buffer,9);
23//	strDT->Append(_T(" "));
24//	strDT->Append(buffer);
25//	strDT->Append(_T("]:"));
26//	return strDT;
27//}
28const char* Log_SQLite::GetDayTimeStr(CString & strTime)
29{
30	const int SIZE = 30;
31	strTime = "[";
32	time_t ltime;
33	TCHAR buf[SIZE];
34	errno_t err;
35    time( &ltime );
36    err = _tctime_s( buf, SIZE, &ltime );
37    if (err != 0)
38    {
39		strTime += buf;
40	}
41	strTime +="]";
42	return (const char*)strTime;
43}
44void Log_SQLite::Log_Error(const char* szFileName, const char* szErrorMessage)
45{
46	if(szFileName==NULL)
47		return ;
48	ofstream wFile(szFileName,ios::app);
49	if(wFile.good())
50	{
51	    CString ptrDT;
52		wFile<< GetDayTimeStr(ptrDT);
53		wFile<<szErrorMessage;	
54	}
55	else
56	{
57		return ;
58	}
59	
60}