mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Utilities: Fixed child process console output being incorrectly cut off at first newline
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
#include "Errors.h"
|
||||
#include "Log.h"
|
||||
#include "Optional.h"
|
||||
#include "Util.h"
|
||||
|
||||
#include "Hacks/boost_1_73_process_windows_nopch.h"
|
||||
|
||||
@@ -54,10 +53,19 @@ public:
|
||||
|
||||
std::streamsize write(char const* str, std::streamsize size)
|
||||
{
|
||||
std::string consoleStr(str, size);
|
||||
RemoveCRLF(consoleStr);
|
||||
callback_(consoleStr);
|
||||
return size;
|
||||
std::string_view consoleStr(str, size);
|
||||
size_t lineEnd = consoleStr.find_first_of("\r\n");
|
||||
std::streamsize processedCharacters = size;
|
||||
if (lineEnd != std::string_view::npos)
|
||||
{
|
||||
consoleStr = consoleStr.substr(0, lineEnd);
|
||||
processedCharacters = lineEnd + 1;
|
||||
}
|
||||
|
||||
if (!consoleStr.empty())
|
||||
callback_(consoleStr);
|
||||
|
||||
return processedCharacters;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,14 +127,14 @@ static int CreateChildProcess(T waiter, std::string const& executable,
|
||||
}
|
||||
}();
|
||||
|
||||
auto outInfo = MakeTCLogSink([&](std::string const& msg)
|
||||
auto outInfo = MakeTCLogSink([&](std::string_view msg)
|
||||
{
|
||||
TC_LOG_INFO(logger, "%s", msg.c_str());
|
||||
TC_LOG_INFO(logger, STRING_VIEW_FMT, STRING_VIEW_FMT_ARG(msg));
|
||||
});
|
||||
|
||||
auto outError = MakeTCLogSink([&](std::string const& msg)
|
||||
auto outError = MakeTCLogSink([&](std::string_view msg)
|
||||
{
|
||||
TC_LOG_ERROR(logger, "%s", msg.c_str());
|
||||
TC_LOG_ERROR(logger, STRING_VIEW_FMT, STRING_VIEW_FMT_ARG(msg));
|
||||
});
|
||||
|
||||
copy(outStream, outInfo);
|
||||
|
||||
Reference in New Issue
Block a user