1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-24 21:11:34 +00:00

Merge branch 'fix-debug-config' into 'master'

Fix Windows Debug build

See merge request OpenMW/openmw!4629
This commit is contained in:
Alexei Kotov 2025-04-12 17:35:03 +03:00
commit f7f148a6ca

View file

@ -106,6 +106,8 @@ namespace Debug
logListener = std::move(listener); logListener = std::move(listener);
} }
namespace
{
class DebugOutputBase : public boost::iostreams::sink class DebugOutputBase : public boost::iostreams::sink
{ {
public: public:
@ -137,7 +139,8 @@ namespace Debug
#endif #endif
prefixSize = std::strftime(prefix + 1, sizeof(prefix) - 1, "%T", &time_info) + 1; prefixSize = std::strftime(prefix + 1, sizeof(prefix) - 1, "%T", &time_info) + 1;
char levelLetter = " EWIVD*"[int(level)]; char levelLetter = " EWIVD*"[int(level)];
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count(); const auto ms
= std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
prefixSize += snprintf(prefix + prefixSize, sizeof(prefix) - prefixSize, ".%03u %c] ", prefixSize += snprintf(prefix + prefixSize, sizeof(prefix) - prefixSize, ".%03u %c] ",
static_cast<unsigned>(ms % 1000), levelLetter); static_cast<unsigned>(ms % 1000), levelLetter);
} }
@ -152,7 +155,8 @@ namespace Debug
writeImpl(prefix, prefixSize, level); writeImpl(prefix, prefixSize, level);
writeImpl(msg.data(), lineSize, level); writeImpl(msg.data(), lineSize, level);
if (logListener) if (logListener)
logListener(level, std::string_view(prefix, prefixSize), std::string_view(msg.data(), lineSize)); logListener(
level, std::string_view(prefix, prefixSize), std::string_view(msg.data(), lineSize));
msg = msg.substr(lineSize); msg = msg.substr(lineSize);
} }
@ -192,8 +196,6 @@ namespace Debug
}; };
#else #else
namespace
{
struct Record struct Record
{ {
std::string mValue; std::string mValue;
@ -324,6 +326,7 @@ namespace Debug
First mFirst; First mFirst;
Second mSecond; Second mSecond;
}; };
#endif
Level toLevel(std::string_view value) Level toLevel(std::string_view value)
{ {
@ -340,8 +343,6 @@ namespace Debug
return Verbose; return Verbose;
} }
}
#endif
static std::unique_ptr<std::ostream> rawStdout = nullptr; static std::unique_ptr<std::ostream> rawStdout = nullptr;
static std::unique_ptr<std::ostream> rawStderr = nullptr; static std::unique_ptr<std::ostream> rawStderr = nullptr;
@ -356,6 +357,7 @@ namespace Debug
static boost::iostreams::stream_buffer<Tee<Buffer, Coloured>> bufferedOut; static boost::iostreams::stream_buffer<Tee<Buffer, Coloured>> bufferedOut;
static boost::iostreams::stream_buffer<Tee<Buffer, Coloured>> bufferedErr; static boost::iostreams::stream_buffer<Tee<Buffer, Coloured>> bufferedErr;
#endif #endif
}
std::ostream& getRawStdout() std::ostream& getRawStdout()
{ {