project64/Source/Project64-core/Logging.cpp

60 lines
1.1 KiB
C++
Raw Normal View History

#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>
#include <Common/path.h>
2015-12-06 09:59:58 +00:00
#include <Project64-core/N64System/SystemGlobals.h>
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
2021-04-14 05:34:15 +00:00
#include <Project64-core/N64System/N64Rom.h>
2021-04-12 11:35:39 +00:00
CFile * CLogging::m_hLogFile = nullptr;
void CLogging::LogMessage(const char * Message, ...)
{
char Msg[400];
va_list ap;
if (!g_Settings->LoadBool(Debugger_Enabled))
{
return;
}
2021-04-12 11:35:39 +00:00
if (m_hLogFile == nullptr)
{
return;
}
va_start(ap, Message);
vsprintf(Msg, Message, ap);
va_end(ap);
strcat(Msg, "\r\n");
2022-08-01 03:45:52 +00:00
m_hLogFile->Write(Msg, (uint32_t)strlen(Msg));
}
void CLogging::StartLog(void)
{
if (!GenerateLog())
{
StopLog();
return;
}
2021-04-12 11:35:39 +00:00
if (m_hLogFile != nullptr)
{
return;
}
2016-03-10 11:15:40 +00:00
CPath LogFile(g_Settings->LoadStringVal(Directory_Log).c_str(), "cpudebug.log");
m_hLogFile = new CFile(LogFile, CFileBase::modeCreate | CFileBase::modeWrite);
}
void CLogging::StopLog(void)
{
if (m_hLogFile)
{
delete m_hLogFile;
2021-04-12 11:35:39 +00:00
m_hLogFile = nullptr;
}
}