mirror of
https://github.com/libretro/Play-.git
synced 2024-12-01 04:30:55 +00:00
b7847f6f6e
git-svn-id: http://svn.purei.org/purei/trunk@1108 b36208d7-6611-0410-8bec-b1987f11c4a2
47 lines
996 B
C++
47 lines
996 B
C++
#include <stdarg.h>
|
|
#include <time.h>
|
|
#include "Log.h"
|
|
#include "AppConfig.h"
|
|
#include "PathUtils.h"
|
|
#include "StdStreamUtils.h"
|
|
|
|
#define LOG_PATH "logs"
|
|
|
|
CLog::CLog()
|
|
{
|
|
#ifndef DISABLE_LOGGING
|
|
m_logBasePath = CAppConfig::GetBasePath() / LOG_PATH;
|
|
Framework::PathUtils::EnsurePathExists(m_logBasePath);
|
|
#endif
|
|
}
|
|
|
|
CLog::~CLog()
|
|
{
|
|
|
|
}
|
|
|
|
void CLog::Print(const char* logName, const char* format, ...)
|
|
{
|
|
#if defined(_DEBUG) && !defined(DISABLE_LOGGING)
|
|
auto& logStream(GetLog(logName));
|
|
va_list args;
|
|
va_start(args, format);
|
|
vfprintf(logStream, format, args);
|
|
va_end(args);
|
|
logStream.Flush();
|
|
#endif
|
|
}
|
|
|
|
Framework::CStdStream& CLog::GetLog(const char* logName)
|
|
{
|
|
auto logIterator(m_logs.find(logName));
|
|
if(logIterator == std::end(m_logs))
|
|
{
|
|
auto logPath = m_logBasePath / (std::string(logName) + ".log");
|
|
auto logStream = Framework::CreateOutputStdStream(logPath.native());
|
|
m_logs[logName] = std::move(logStream);
|
|
logIterator = m_logs.find(logName);
|
|
}
|
|
return logIterator->second;
|
|
}
|