recording: Updated all current logging instances to use new logger

This commit is contained in:
Tyler Wilding 2020-09-24 22:52:25 -04:00 committed by refractionpcsx2
parent b8f4fa0e87
commit 8decc44476
5 changed files with 50 additions and 42 deletions

View File

@ -27,6 +27,7 @@
#include "InputRecording.h"
#include "InputRecordingControls.h"
#include "Utilities/InputRecordingLogger.h"
#endif
@ -221,7 +222,7 @@ void InputRecording::SetToRecordMode()
state = InputRecordingMode::Recording;
virtualPads[CONTROLLER_PORT_ONE]->SetReadOnlyMode(false);
virtualPads[CONTROLLER_PORT_TWO]->SetReadOnlyMode(false);
recordingConLog("[REC]: Record mode ON.\n");
inputRec::log("Record mode ON");
}
void InputRecording::SetToReplayMode()
@ -229,15 +230,15 @@ void InputRecording::SetToReplayMode()
state = InputRecordingMode::Replaying;
virtualPads[CONTROLLER_PORT_ONE]->SetReadOnlyMode(true);
virtualPads[CONTROLLER_PORT_TWO]->SetReadOnlyMode(true);
recordingConLog("[REC]: Replay mode ON.\n");
inputRec::log("Replay mode ON");
}
void InputRecording::SetFrameCounter(u32 newGFrameCount)
{
if (newGFrameCount > startingFrame + (u32)g_InputRecording.GetInputRecordingData().GetTotalFrames())
{
recordingConLog(L"[REC]: Warning, you've loaded PCSX2 emulation to a point after the end of the original recording. This should be avoided.\n");
recordingConLog(L"[REC]: Savestate's framecount has been ignored.\n");
inputRec::consoleLog("Warning, you've loaded PCSX2 emulation to a point after the end of the original recording. This should be avoided.");
inputRec::consoleLog("Savestate's framecount has been ignored.");
frameCounter = g_InputRecording.GetInputRecordingData().GetTotalFrames();
if (state == InputRecordingMode::Replaying)
SetToRecordMode();
@ -247,7 +248,7 @@ void InputRecording::SetFrameCounter(u32 newGFrameCount)
{
if (newGFrameCount < startingFrame)
{
recordingConLog(L"[REC]: Warning, you've loaded PCSX2 emulation to a point before the start of the original recording. This should be avoided.\n");
inputRec::consoleLog("Warning, you've loaded PCSX2 emulation to a point before the start of the original recording. This should be avoided.");
if (state == InputRecordingMode::Recording)
SetToReplayMode();
}
@ -261,9 +262,8 @@ void InputRecording::SetFrameCounter(u32 newGFrameCount)
void InputRecording::SetStartingFrame(u32 newStartingFrame)
{
startingFrame = newStartingFrame;
// TODO - make a function of my own to simplify working with the logging macros
if (inputRecordingData.FromSaveState())
recordingConLog(wxString::Format(L"[REC]: Internal Starting Frame: %d\n", startingFrame));
inputRec::consoleLog("Internal Starting Frame: %d", startingFrame);
frameCounter = 0;
initialLoad = false;
g_InputRecordingControls.Lock(startingFrame);
@ -276,7 +276,7 @@ void InputRecording::Stop()
virtualPads[CONTROLLER_PORT_TWO]->SetReadOnlyMode(false);
incrementUndo = false;
if (inputRecordingData.Close())
recordingConLog(L"[REC]: InputRecording Recording Stopped.\n");
inputRec::log("Input recording stopped");
}
bool InputRecording::Create(wxString FileName, bool fromSaveState, wxString authorName)
@ -307,7 +307,8 @@ bool InputRecording::Create(wxString FileName, bool fromSaveState, wxString auth
inputRecordingData.WriteHeader();
SetToRecordMode();
g_InputRecordingControls.DisableFrameAdvance();
recordingConLog(wxString::Format(L"[REC]: Started new recording - [%s]\n", FileName));
inputRec::log("Started new input recording");
inputRec::consoleLog("Filename %s", std::string(FileName));
return true;
}
@ -324,14 +325,14 @@ bool InputRecording::Play(wxString fileName)
{
if (!CoreThread.IsOpen())
{
recordingConLog(L"[REC]: Game is not open, aborting playing input recording which starts on a save-state.\n");
inputRec::consoleLog("Game is not open, aborting playing input recording which starts on a save-state.");
inputRecordingData.Close();
return false;
}
if (!wxFileExists(inputRecordingData.GetFilename() + "_SaveState.p2s"))
{
recordingConLog(wxString::Format("[REC]: Could not locate savestate file at location - %s_SaveState.p2s\n",
inputRecordingData.GetFilename()));
inputRec::consoleLog("Could not locate savestate file at location - %s_SaveState.p2s",
inputRecordingData.GetFilename());
inputRecordingData.Close();
return false;
}
@ -347,18 +348,19 @@ bool InputRecording::Play(wxString fileName)
// Check if the current game matches with the one used to make the original recording
if (!g_Conf->CurrentIso.IsEmpty())
if (resolveGameName() != inputRecordingData.GetHeader().gameName)
recordingConLog(L"[REC]: Recording was possibly constructed for a different game.\n");
inputRec::consoleLog("Input recording was possibly constructed for a different game.");
incrementUndo = true;
SetToReplayMode();
inputRec::log("Playing input recording");
g_InputRecordingControls.DisableFrameAdvance();
recordingConLog(wxString::Format(L"[REC]: Replaying input recording - [%s]\n", inputRecordingData.GetFilename()));
recordingConLog(wxString::Format(L"[REC]: PCSX2 Version Used: %s\n", inputRecordingData.GetHeader().emu));
recordingConLog(wxString::Format(L"[REC]: Recording File Version: %d\n", inputRecordingData.GetHeader().version));
recordingConLog(wxString::Format(L"[REC]: Associated Game Name or ISO Filename: %s\n", inputRecordingData.GetHeader().gameName));
recordingConLog(wxString::Format(L"[REC]: Author: %s\n", inputRecordingData.GetHeader().author));
recordingConLog(wxString::Format(L"[REC]: Total Frames: %d\n", inputRecordingData.GetTotalFrames()));
recordingConLog(wxString::Format(L"[REC]: Undo Count: %d\n", inputRecordingData.GetUndoCount()));
inputRec::consoleMultiLog({wxString::Format("Replaying input recording - [%s]", std::string(inputRecordingData.GetFilename())),
wxString::Format("PCSX2 Version Used: %s", std::string(inputRecordingData.GetHeader().emu)),
wxString::Format("Recording File Version: %d", inputRecordingData.GetHeader().version),
wxString::Format("Associated Game Name or ISO Filename: %s", std::string(inputRecordingData.GetHeader().gameName)),
wxString::Format("Author: %s", inputRecordingData.GetHeader().author),
wxString::Format("Total Frames: %d", inputRecordingData.GetTotalFrames()),
wxString::Format("Undo Count: %d", inputRecordingData.GetUndoCount())});
return true;
}

View File

@ -25,7 +25,7 @@
#include "InputRecording.h"
#include "InputRecordingControls.h"
#include "Utilities/InputRecordingLogger.h"
InputRecordingControls g_InputRecordingControls;
@ -43,7 +43,7 @@ void InputRecordingControls::HandleFrameAdvanceAndPausing()
if (g_FrameCount == frameCountTracker)
{
frameLock = false;
g_InputRecordingControls.Resume();
Resume();
}
else if (!emulationCurrentlyPaused && CoreThread.IsOpen() && CoreThread.IsRunning())
{
@ -79,8 +79,9 @@ void InputRecordingControls::HandleFrameAdvanceAndPausing()
switchToReplay = false;
}
if ((g_InputRecording.IsReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
|| g_InputRecording.GetFrameCounter() == INT_MAX)
if ((g_InputRecording.IsReplaying() &&
g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames()) ||
g_InputRecording.GetFrameCounter() == INT_MAX)
pauseEmulation = true;
// If we haven't yet advanced atleast a single frame from when we paused, setup things to be paused
@ -110,8 +111,8 @@ void InputRecordingControls::ResumeCoreThreadIfStarted()
void InputRecordingControls::FrameAdvance()
{
if (g_InputRecording.IsReplaying()
&& g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
if (g_InputRecording.IsReplaying() &&
g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
{
g_InputRecording.SetToRecordMode();
return;
@ -146,8 +147,8 @@ void InputRecordingControls::PauseImmediately()
void InputRecordingControls::Resume()
{
if (g_InputRecording.IsReplaying()
&& g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
if (g_InputRecording.IsReplaying() &&
g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
{
g_InputRecording.SetToRecordMode();
return;
@ -168,20 +169,23 @@ void InputRecordingControls::DisableFrameAdvance()
void InputRecordingControls::TogglePause()
{
if (pauseEmulation && g_InputRecording.IsReplaying()
&& g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
if (pauseEmulation &&
g_InputRecording.IsReplaying() &&
g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
{
g_InputRecording.SetToRecordMode();
return;
}
pauseEmulation = !pauseEmulation;
resumeEmulation = !pauseEmulation;
inputRec::log(pauseEmulation ? "Paused Emulation" : "Resumed Emulation");
}
void InputRecordingControls::RecordModeToggle()
{
if (IsPaused() || g_InputRecording.IsReplaying()
|| g_InputRecording.GetFrameCounter() < g_InputRecording.GetInputRecordingData().GetTotalFrames())
if (IsPaused() ||
g_InputRecording.IsReplaying() ||
g_InputRecording.GetFrameCounter() < g_InputRecording.GetInputRecordingData().GetTotalFrames())
{
if (g_InputRecording.IsReplaying())
g_InputRecording.SetToRecordMode();

View File

@ -21,7 +21,8 @@
#include "MainFrame.h"
#include "MemoryTypes.h"
#include "Recording/InputRecordingFile.h"
#include "InputRecordingFile.h"
#include "Utilities/InputRecordingLogger.h"
void InputRecordingFileHeader::Init()
{
@ -120,10 +121,10 @@ bool InputRecordingFile::open(const wxString path, bool newRecording)
return true;
}
Close();
recordingConLog(wxString::Format("[REC]: Input recording file header is invalid\n"));
inputRec::consoleLog("Input recording file header is invalid");
return false;
}
recordingConLog(wxString::Format("[REC]: Input recording file opening failed. Error - %s\n", strerror(errno)));
inputRec::consoleLog("Input recording file opening failed. Error - %s", strerror(errno));
return false;
}
@ -140,7 +141,7 @@ bool InputRecordingFile::OpenNew(const wxString path, bool fromSavestate)
}
}
else
recordingConLog(L"[REC]: Game is not open, aborting playing input recording which starts on a save-state.\n");
inputRec::consoleLog("Game is not open, aborting playing input recording which starts on a save-state.");
return false;
}
else if (open(path, true))
@ -242,7 +243,7 @@ bool InputRecordingFile::verifyRecordingFileHeader()
// Check for current verison
if (header.version != 1)
{
recordingConLog(wxString::Format("[REC]: Input recording file is not a supported version - %d\n", header.version));
inputRec::consoleLog("Input recording file is not a supported version - %d", header.version);
return false;
}
return true;

View File

@ -27,6 +27,7 @@
#ifndef DISABLE_RECORDING
# include "Recording/InputRecording.h"
# include "Recording/Utilities/InputRecordingLogger.h"
#endif
#include <wx/utils.h>
@ -142,7 +143,7 @@ void GSPanel::InitRecordingAccelerators()
m_Accels->findKeycodeWithCommandId("InputRecordingModeToggle").toTitleizedString(),
g_InputRecording.IsActive());
recordingConLog(L"Initialized Input Recording Key Bindings\n");
inputRec::consoleLog("Initialized Input Recording Key Bindings");
}
void GSPanel::RemoveRecordingAccelerators()