Play-/Source/Log.cpp
jpd002 fdd1734ff0 MacOSX
git-svn-id: http://svn.purei.org/purei/trunk@197 b36208d7-6611-0410-8bec-b1987f11c4a2
2007-12-12 03:09:57 +00:00

47 lines
804 B
C++

#include <stdarg.h>
#include <time.h>
#include "Log.h"
#define LOG_PATH "./logs/"
using namespace Framework;
using namespace std;
CLog::CLog()
{
}
CLog::~CLog()
{
}
void CLog::Print(const char* logName, const char* format, ...)
{
#ifdef _DEBUG
CStdStream* log(GetLog(logName));
if(log == NULL) return;
va_list args;
va_start(args, format);
vfprintf(*log, format, args);
va_end(args);
log->Flush();
#endif
}
CStdStream* CLog::GetLog(const char* logName)
{
LogMapType::iterator logIterator(m_logs.find(logName));
if(logIterator != m_logs.end())
{
return logIterator->second;
}
else
{
CStdStream* log = new CStdStream((LOG_PATH + string(logName) + ".log").c_str(), "wb");
m_logs[logName] = log;
return log;
}
}