diff options
| author | 2025-01-17 13:43:05 +0000 | |
|---|---|---|
| committer | 2025-01-17 13:57:32 +0000 | |
| commit | 7dbbc78421e3c5296d297190649ed58e4bcf052c (patch) | |
| tree | 30af3b95f473a4a9234763f642e717f3a25dab70 /src/logging.cpp | |
| parent | Move the starttls module to the contrib repository. (diff) | |
| parent | Run irctest on AArch64. (diff) | |
Merge branch 'insp4' into master.
Diffstat (limited to 'src/logging.cpp')
| -rw-r--r-- | src/logging.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/logging.cpp b/src/logging.cpp index daf6100f1..aa8d7d705 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -224,7 +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(); + CheckLevel(); return; } @@ -232,7 +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(); + CheckLevel(); return; } @@ -291,7 +291,7 @@ void Log::Manager::OpenLogs(bool requiremethods) cache.shrink_to_fit(); caching = false; } - CheckRawLog(); + CheckLevel(); } void Log::Manager::RegisterServices() @@ -310,12 +310,20 @@ 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() +void Log::Manager::CheckLevel() { // 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; - }); + auto newmaxlevel = Level::LOWEST; + for (const auto& logger : loggers) + { + if (logger.level > newmaxlevel) + newmaxlevel = logger.level; + } + + std::swap(maxlevel, newmaxlevel); + ServerInstance->Config->RawLog = (newmaxlevel >= Level::RAWIO); + + Debug("LOG", "Changed maximum log level from {} to {}", LevelToString(newmaxlevel), LevelToString(maxlevel)); } void Log::Manager::Write(Level level, const std::string& type, const std::string& message) @@ -323,6 +331,9 @@ void Log::Manager::Write(Level level, const std::string& type, const std::string if (logging) return; // Avoid log loops. + if (maxlevel < level && !caching) + return; // No loggers care about this message. + logging = true; time_t time = ServerInstance->Time(); for (auto& logger : loggers) |
