Skip to content

Commit

Permalink
recording: Add logging header to simplify input recording logging
Browse files Browse the repository at this point in the history
Appends [REC] to console logs when appropriate.  Auto appends new-line.  Sends similar logs to OSD if desired.
  • Loading branch information
xTVaser authored and refractionpcsx2 committed Oct 17, 2020
1 parent bab8bdf commit 0fede4c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions pcsx2/CMakeLists.txt
Expand Up @@ -555,6 +555,7 @@ set(pcsx2RecordingHeaders
${rec_src}/InputRecordingFile.h
${rec_src}/NewRecordingFrame.h
${rec_src}/PadData.h
${rec_src}/Utilities/InputRecordingLogger.h
${rec_vp_src}/VirtualPad.h
${rec_vp_src}/VirtualPadData.h
${rec_vp_src}/VirtualPadResources.h
Expand Down
69 changes: 69 additions & 0 deletions pcsx2/Recording/Utilities/InputRecordingLogger.h
@@ -0,0 +1,69 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "App.h"
#include "ConsoleLogger.h"
#include "DebugTools/Debug.h"
#include "Utilities/Console.h"

#include <fmt/core.h>

#include <memory>
#include <string>
#include <vector>

namespace inputRec
{
static void log(const std::string& log)
{
if (log.empty())
return;

recordingConLog(fmt::format("[REC]: %s\n", log));

// NOTE - Color is not currently used for OSD logs
if (GSosdLog)
GSosdLog(log.c_str(), wxGetApp().GetProgramLog()->GetRGBA(ConsoleColors::Color_StrongMagenta));
}

static void consoleLog(const std::string& log)
{
if (log.empty())
return;

recordingConLog(fmt::format("[REC]: %s\n", log));
}

static void consoleMultiLog(std::vector<std::string> logs)
{
std::string log;
for (std::string l : logs)
log.append(fmt::format("[REC]: %s\n", l));

recordingConLog(log);
}


static void consoleMultiLog(std::vector<wxString> logs)
{
std::vector<std::string> stdLogs;
for (wxString l : logs)
stdLogs.push_back(std::string(l));

consoleMultiLog(stdLogs);
}
} // namespace inputRec
1 change: 1 addition & 0 deletions pcsx2/windows/VCprojects/pcsx2.vcxproj
Expand Up @@ -598,6 +598,7 @@
<ClInclude Include="..\..\Recording\VirtualPad\VirtualPad.h" />
<ClInclude Include="..\..\Recording\VirtualPad\VirtualPadData.h" />
<ClInclude Include="..\..\Recording\VirtualPad\VirtualPadResources.h" />
<ClInclude Include="..\..\Recording\Utilities\InputRecordingLogger.h" />
<ClInclude Include="..\..\Utilities\AsciiFile.h" />
<ClInclude Include="..\..\Elfheader.h" />
<ClInclude Include="..\..\CDVD\IsoFileFormats.h" />
Expand Down
6 changes: 6 additions & 0 deletions pcsx2/windows/VCprojects/pcsx2.vcxproj.filters
Expand Up @@ -163,6 +163,9 @@
<Filter Include="System\Ps2\SPU2">
<UniqueIdentifier>{bed493d6-96dc-4057-a1f2-31f88ec927d9}</UniqueIdentifier>
</Filter>
<Filter Include="Recording\Utilities">
<UniqueIdentifier>{85c5a0d2-6404-439f-8756-d908a1442b96}</UniqueIdentifier>
</Filter>
<Filter Include="Recording\VirtualPad\Images">
<UniqueIdentifier>{ad528458-08eb-49a2-aefa-3c2b86ab8896}</UniqueIdentifier>
</Filter>
Expand Down Expand Up @@ -1518,6 +1521,9 @@
<ClInclude Include="..\..\SPU2\Windows\WinConfig.h">
<Filter>System\Ps2\SPU2</Filter>
</ClInclude>
<ClInclude Include="..\..\Recording\Utilities\InputRecordingLogger.h">
<Filter>Recording\Utilities</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\wxResources.rc">
Expand Down

0 comments on commit 0fede4c

Please sign in to comment.