Fix rawio logs not being written after a rehash.

This commit is contained in:
Sadie Powell 2024-09-09 11:29:08 +01:00
parent a3668d75d6
commit b5032fb641
2 changed files with 14 additions and 5 deletions

View File

@ -236,6 +236,9 @@ private:
/** Whether we are currently logging to a file. */
bool logging = false;
/** Check whether raw logging is enabled. */
void CheckRawLog();
/** Writes a message to the server log.
* @param level The level to log at.
* @param type The type of message that is being logged.

View File

@ -224,6 +224,7 @@ void Log::Manager::OpenLogs(bool requiremethods)
{
const auto* option = ServerInstance->Config->CommandLine.forceprotodebug ? "--protocoldebug" : "--debug";
Normal("LOG", "Not opening loggers because we were started with {}", option);
CheckRawLog();
return;
}
@ -231,6 +232,7 @@ void Log::Manager::OpenLogs(bool requiremethods)
if (!ServerInstance->Config->CommandLine.writelog)
{
Normal("LOG", "Not opening loggers because we were started with --nolog");
CheckRawLog();
return;
}
@ -295,11 +297,7 @@ void Log::Manager::OpenLogs(bool requiremethods)
cache.shrink_to_fit();
caching = false;
}
// There might be a logger not from the config so we need to check this outside of the creation loop.
ServerInstance->Config->RawLog = std::any_of(loggers.begin(), loggers.end(), [](const auto& logger) {
return logger.level >= Level::RAWIO;
});
CheckRawLog();
}
void Log::Manager::RegisterServices()
@ -318,6 +316,14 @@ void Log::Manager::UnloadEngine(const Engine* engine)
Normal("LOG", "The {} log engine is unloading; removed {}/{} loggers.", engine->name.c_str(), logger_count - loggers.size(), logger_count);
}
void Log::Manager::CheckRawLog()
{
// There might be a logger not from the config so we need to check this outside of the creation loop.
ServerInstance->Config->RawLog = std::any_of(loggers.begin(), loggers.end(), [](const auto& logger) {
return logger.level >= Level::RAWIO;
});
}
void Log::Manager::Write(Level level, const std::string& type, const std::string& message)
{
if (logging)