2016-01-27 09:11:59 +00:00
|
|
|
#include "stdafx.h"
|
2016-06-27 07:26:35 +00:00
|
|
|
#include "RecompilerCodeLog.h"
|
2016-01-27 09:11:59 +00:00
|
|
|
#include <Common/path.h>
|
2016-04-20 09:16:02 +00:00
|
|
|
#include <Common/Platform.h>
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2017-07-30 16:47:06 +00:00
|
|
|
/* vsprintf() */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2016-04-19 10:38:14 +00:00
|
|
|
static CLog * g_CPULogFile = NULL;
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2016-06-27 07:26:35 +00:00
|
|
|
void Recompiler_Log_Message(const char * strFormat, ...)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2016-04-19 10:38:14 +00:00
|
|
|
va_list args;
|
|
|
|
va_start(args, strFormat);
|
2018-02-13 06:38:33 +00:00
|
|
|
size_t nlen = _vscprintf(strFormat, args) + 1;
|
2018-01-20 22:10:45 +00:00
|
|
|
char * buffer = (char *)alloca((nlen + 3) * sizeof(char));
|
2016-04-19 10:38:14 +00:00
|
|
|
if (buffer != NULL)
|
|
|
|
{
|
2018-01-20 22:10:45 +00:00
|
|
|
if (nlen > 0)
|
|
|
|
{
|
|
|
|
vsnprintf(buffer, nlen, strFormat, args);
|
|
|
|
buffer[nlen - 1] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buffer[0] = '\0';
|
|
|
|
}
|
2016-04-19 10:38:14 +00:00
|
|
|
strcat(buffer, "\r\n");
|
|
|
|
g_CPULogFile->Log(buffer);
|
|
|
|
}
|
|
|
|
va_end(args);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 07:26:35 +00:00
|
|
|
void Start_Recompiler_Log (void)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2016-03-10 11:15:40 +00:00
|
|
|
CPath LogFileName(g_Settings->LoadStringVal(Directory_Log).c_str(), "CPUoutput.log");
|
2016-04-19 10:38:14 +00:00
|
|
|
if (g_CPULogFile != NULL)
|
|
|
|
{
|
2016-06-27 07:26:35 +00:00
|
|
|
Stop_Recompiler_Log();
|
2016-04-19 10:38:14 +00:00
|
|
|
}
|
|
|
|
g_CPULogFile = new CLog();
|
|
|
|
if (g_CPULogFile)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2016-04-19 10:38:14 +00:00
|
|
|
if (g_CPULogFile->Open(LogFileName))
|
|
|
|
{
|
|
|
|
g_CPULogFile->SetMaxFileSize(300 * CLog::MB);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete g_CPULogFile;
|
|
|
|
g_CPULogFile = NULL;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-27 07:26:35 +00:00
|
|
|
void Stop_Recompiler_Log (void)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2016-04-19 10:38:14 +00:00
|
|
|
if (g_CPULogFile != NULL)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2016-04-19 10:38:14 +00:00
|
|
|
delete g_CPULogFile;
|
|
|
|
g_CPULogFile = NULL;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-03 05:38:44 +00:00
|
|
|
|
|
|
|
void Flush_Recompiler_Log(void)
|
|
|
|
{
|
|
|
|
if (g_CPULogFile != NULL)
|
|
|
|
{
|
|
|
|
g_CPULogFile->Flush();
|
|
|
|
}
|
|
|
|
}
|