From d02fc5f4bb1733a0cfd45ee00b4a8e3ff2a53ca3 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Wed, 4 Nov 2026 18:58:44 -0600 Subject: Common/Logging/LogManager: Add IsListenerEnabled function to avoid string formatting when log types are enabled but all listeners are disabled. Also eliminate redundant IsEnabled(type, level) check. --- Source/Core/Common/Logging/LogManager.cpp | 5 +---- Source/Core/Common/Logging/LogManager.h | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp index 5a586623cb..ae3ea6a66c 100644 --- a/Source/Core/Common/Logging/LogManager.cpp +++ b/Source/Core/Common/Logging/LogManager.cpp @@ -65,7 +65,7 @@ void GenericLogFmtImpl(LogLevel level, LogType type, const char* file, int line, if (instance == nullptr) return; - if (!instance->IsEnabled(type, level)) + if (!instance->IsEnabled(type, level) || !instance->IsAnyListenerEnabled()) return; const auto message = fmt::vformat(format, args); @@ -193,9 +193,6 @@ void LogManager::SaveSettings() void LogManager::Log(LogLevel level, LogType type, const char* file, int line, const char* message) { - if (!IsEnabled(type, level) || !static_cast(m_listener_ids)) - return; - LogWithFullPath(level, type, file + GetPathCutOffPoint(), line, message); } diff --git a/Source/Core/Common/Logging/LogManager.h b/Source/Core/Common/Logging/LogManager.h index 624cd1e697..7e145b0da1 100644 --- a/Source/Core/Common/Logging/LogManager.h +++ b/Source/Core/Common/Logging/LogManager.h @@ -75,6 +75,7 @@ public: void RegisterListener(LogListener::LISTENER id, std::unique_ptr listener); void EnableListener(LogListener::LISTENER id, bool enable); bool IsListenerEnabled(LogListener::LISTENER id) const; + bool IsAnyListenerEnabled() const { return static_cast(m_listener_ids); } void SaveSettings(); -- cgit v1.2.3