diff --git a/include/quill/backend/SignalHandler.h b/include/quill/backend/SignalHandler.h index 13705dd6..58b553d1 100644 --- a/include/quill/backend/SignalHandler.h +++ b/include/quill/backend/SignalHandler.h @@ -44,7 +44,7 @@ QUILL_BEGIN_NAMESPACE namespace detail { -static constexpr std::initializer_list excluded_logger_name_substr = {"__csv__"}; +static constexpr std::string_view excluded_logger_name_substr = {"__csv__"}; /***/ class SignalHandlerContext diff --git a/include/quill/core/LoggerManager.h b/include/quill/core/LoggerManager.h index a8e63bd7..1ad6e632 100644 --- a/include/quill/core/LoggerManager.h +++ b/include/quill/core/LoggerManager.h @@ -70,7 +70,7 @@ class LoggerManager } /***/ - QUILL_NODISCARD LoggerBase* get_valid_logger(std::initializer_list exclude_logger_substrs = {}) const + QUILL_NODISCARD LoggerBase* get_valid_logger(std::string_view exclude_logger_substr = {}) const { // Retrieves any valid logger without the need for constructing a vector LockGuard const lock{_spinlock}; @@ -80,19 +80,11 @@ class LoggerManager // we can not add invalidated loggers as they can be removed at any time if (elem->is_valid_logger()) { - // Check if any of the excluded substrings are found in the logger name - if (std::any_of(exclude_logger_substrs.begin(), exclude_logger_substrs.end(), - [&elem](std::string_view exclude_substr) - { - return elem->get_logger_name().find(exclude_substr) != std::string::npos; - })) + if (elem->get_logger_name().find(exclude_logger_substr) == std::string::npos) { - // Skip this logger since it matches an excluded substring - continue; + // Use this logger since it doesn't include the an excluded substring + return elem.get(); } - - // No excluded substring found, return this logger - return elem.get(); } } diff --git a/test/integration_tests/SignalHandlerTest.cpp b/test/integration_tests/SignalHandlerTest.cpp index e9bd291d..6da7dcc9 100644 --- a/test/integration_tests/SignalHandlerTest.cpp +++ b/test/integration_tests/SignalHandlerTest.cpp @@ -2,16 +2,16 @@ #include "misc/TestUtilities.h" #include "quill/Backend.h" +#include "quill/CsvWriter.h" #include "quill/Frontend.h" #include "quill/LogMacros.h" -#include "quill/CsvWriter.h" #include "quill/sinks/FileSink.h" #include +#include #include #include #include -#include using namespace quill;