2015-11-13 13:23:43 +00:00
|
|
|
#include "stdafx.h"
|
2016-01-13 07:23:22 +00:00
|
|
|
#include <Project64-core/Logging.h>
|
2015-12-21 19:41:08 +00:00
|
|
|
|
2015-12-21 19:46:04 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
2015-11-13 13:23:43 +00:00
|
|
|
#include <Common/path.h>
|
2015-12-06 09:59:58 +00:00
|
|
|
#include <Project64-core/N64System/SystemGlobals.h>
|
2015-12-21 07:35:22 +00:00
|
|
|
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
2021-04-14 05:34:15 +00:00
|
|
|
#include <Project64-core/N64System/N64Rom.h>
|
2015-11-13 13:23:43 +00:00
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
CFile * CLogging::m_hLogFile = nullptr;
|
2015-11-13 13:23:43 +00:00
|
|
|
|
|
|
|
void CLogging::LogMessage(const char * Message, ...)
|
|
|
|
{
|
2015-12-21 07:16:29 +00:00
|
|
|
char Msg[400];
|
|
|
|
va_list ap;
|
2015-11-13 13:23:43 +00:00
|
|
|
|
2015-12-21 07:16:29 +00:00
|
|
|
if (!g_Settings->LoadBool(Debugger_Enabled))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2021-04-12 11:35:39 +00:00
|
|
|
if (m_hLogFile == nullptr)
|
2015-12-21 07:16:29 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-11-13 13:23:43 +00:00
|
|
|
|
2015-12-21 07:16:29 +00:00
|
|
|
va_start(ap, Message);
|
|
|
|
vsprintf(Msg, Message, ap);
|
|
|
|
va_end(ap);
|
2015-11-13 13:23:43 +00:00
|
|
|
|
2015-12-21 07:16:29 +00:00
|
|
|
strcat(Msg, "\r\n");
|
2015-11-13 13:23:43 +00:00
|
|
|
|
2015-12-21 07:16:29 +00:00
|
|
|
m_hLogFile->Write(Msg, strlen(Msg));
|
2015-11-13 13:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLogging::StartLog(void)
|
|
|
|
{
|
2015-12-21 07:16:29 +00:00
|
|
|
if (!GenerateLog())
|
|
|
|
{
|
|
|
|
StopLog();
|
|
|
|
return;
|
|
|
|
}
|
2021-04-12 11:35:39 +00:00
|
|
|
if (m_hLogFile != nullptr)
|
2015-12-21 07:16:29 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-10 11:15:40 +00:00
|
|
|
CPath LogFile(g_Settings->LoadStringVal(Directory_Log).c_str(), "cpudebug.log");
|
2015-11-13 13:23:43 +00:00
|
|
|
m_hLogFile = new CFile(LogFile, CFileBase::modeCreate | CFileBase::modeWrite);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CLogging::StopLog(void)
|
|
|
|
{
|
2015-12-21 07:16:29 +00:00
|
|
|
if (m_hLogFile)
|
|
|
|
{
|
2015-11-13 13:23:43 +00:00
|
|
|
delete m_hLogFile;
|
2021-04-12 11:35:39 +00:00
|
|
|
m_hLogFile = nullptr;
|
2015-12-21 07:16:29 +00:00
|
|
|
}
|
2021-04-02 07:33:39 +00:00
|
|
|
}
|