mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix logging of replay info to stdout (#14430)
Use Console::WriteLine and replace \n with \r\n.
This commit is contained in:
parent
984a660ad7
commit
c63e072974
|
@ -837,7 +837,7 @@ void start_silent_record()
|
|||
safe_strcpy(gSilentRecordingName, info.FilePath.c_str(), MAX_PATH);
|
||||
|
||||
const char* logFmt = "Silent replay recording started: (%s) %s\n";
|
||||
printf(logFmt, info.Name.c_str(), info.FilePath.c_str());
|
||||
Console::WriteLine(logFmt, info.Name.c_str(), info.FilePath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -859,7 +859,7 @@ bool stop_silent_record()
|
|||
" Commands: %u\n"
|
||||
" Checksums: %u";
|
||||
|
||||
printf(logFmt, info.Name.c_str(), info.FilePath.c_str(), info.Ticks, info.NumCommands, info.NumChecksums);
|
||||
Console::WriteLine(logFmt, info.Name.c_str(), info.FilePath.c_str(), info.Ticks, info.NumCommands, info.NumChecksums);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "../actions/SetCheatAction.h"
|
||||
#include "../actions/StaffSetCostumeAction.h"
|
||||
#include "../config/Config.h"
|
||||
#include "../core/Console.hpp"
|
||||
#include "../core/Guard.hpp"
|
||||
#include "../core/Path.hpp"
|
||||
#include "../core/String.hpp"
|
||||
|
@ -1434,7 +1435,7 @@ static int32_t cc_replay_startrecord(InteractiveConsole& console, const argument
|
|||
|
||||
const char* logFmt = "Replay recording started: (%s) %s";
|
||||
console.WriteFormatLine(logFmt, info.Name.c_str(), info.FilePath.c_str());
|
||||
log_info(logFmt, info.Name.c_str(), info.FilePath.c_str());
|
||||
Console::WriteLine(logFmt, info.Name.c_str(), info.FilePath.c_str());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1469,7 +1470,7 @@ static int32_t cc_replay_stoprecord(InteractiveConsole& console, const arguments
|
|||
|
||||
console.WriteFormatLine(
|
||||
logFmt, info.Name.c_str(), info.FilePath.c_str(), info.Ticks, info.NumCommands, info.NumChecksums);
|
||||
log_info(logFmt, info.Name.c_str(), info.FilePath.c_str(), info.Ticks, info.NumCommands, info.NumChecksums);
|
||||
Console::WriteLine(logFmt, info.Name.c_str(), info.FilePath.c_str(), info.Ticks, info.NumCommands, info.NumChecksums);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1511,7 +1512,7 @@ static int32_t cc_replay_start(InteractiveConsole& console, const arguments_t& a
|
|||
" Checksums: %u";
|
||||
|
||||
console.WriteFormatLine(logFmt, info.FilePath.c_str(), recordingDate, info.Ticks, info.NumCommands, info.NumChecksums);
|
||||
log_info(logFmt, info.FilePath.c_str(), recordingDate, info.Ticks, info.NumCommands, info.NumChecksums);
|
||||
Console::WriteLine(logFmt, info.FilePath.c_str(), recordingDate, info.Ticks, info.NumCommands, info.NumChecksums);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1661,7 +1662,6 @@ static int32_t cc_assert([[maybe_unused]] InteractiveConsole& console, [[maybe_u
|
|||
|
||||
static int32_t cc_add_news_item([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv)
|
||||
{
|
||||
printf("argv.size() = %zu\n", argv.size());
|
||||
if (argv.size() < 2)
|
||||
{
|
||||
console.WriteLineWarning("Too few arguments");
|
||||
|
|
|
@ -134,7 +134,23 @@ void StdInOutConsole::WriteLine(const std::string& s, FormatToken colourFormat)
|
|||
{
|
||||
if (_isPromptShowing)
|
||||
{
|
||||
std::printf("\r%s%s\x1b[0m\x1b[0K\r\n", formatBegin.c_str(), s.c_str());
|
||||
auto* mainString = s.c_str();
|
||||
|
||||
// If string contains \n, we need to replace with \r\n
|
||||
std::string newString;
|
||||
if (s.find('\n') != std::string::npos)
|
||||
{
|
||||
for (auto ch : s)
|
||||
{
|
||||
if (ch == '\n')
|
||||
newString += "\r\n";
|
||||
else
|
||||
newString += ch;
|
||||
}
|
||||
mainString = newString.c_str();
|
||||
}
|
||||
|
||||
std::printf("\r%s%s\x1b[0m\x1b[0K\r\n", formatBegin.c_str(), mainString);
|
||||
std::fflush(stdout);
|
||||
linenoise::linenoiseEditRefreshLine();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue