project64/Source/Project64-core/N64System/Recompiler/RecompilerCodeLog.cpp

72 lines
2.0 KiB
C++
Raw Normal View History

2016-01-27 09:11:59 +00:00
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#include "stdafx.h"
#include "RecompilerCodeLog.h"
2016-01-27 09:11:59 +00:00
#include <Common/path.h>
#include <Common/Platform.h>
2016-01-27 09:11:59 +00:00
2016-04-19 10:38:14 +00:00
static CLog * g_CPULogFile = NULL;
2016-01-27 09:11:59 +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);
size_t nlen = _vscprintf(strFormat, args) + 3;
char * buffer = (char *)alloca(nlen * sizeof(char));
if (buffer != NULL)
{
buffer[nlen - 1] = 0;
vsprintf(buffer, strFormat, args);
strcat(buffer, "\r\n");
g_CPULogFile->Log(buffer);
}
va_end(args);
2016-01-27 09:11:59 +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)
{
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
}
}
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
}
}
void Flush_Recompiler_Log(void)
{
if (g_CPULogFile != NULL)
{
g_CPULogFile->Flush();
}
}