From 7f89a813680eb095e06d4ed9c1e73fc0d3286b2d Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Fri, 1 Nov 2024 17:00:58 +0000 Subject: [PATCH] add count based throttling macros and a counter to time based ones --- docs/logging_macros.rst | 54 +++++ examples/console_logging.cpp | 14 +- examples/json_console_logging.cpp | 19 ++ include/quill/LogMacros.h | 292 +++++++++++++++++++++++--- include/quill/core/MacroMetadata.h | 78 +++---- test/integration_tests/MacrosTest.cpp | 135 +++++++++--- 6 files changed, 491 insertions(+), 101 deletions(-) diff --git a/docs/logging_macros.rst b/docs/logging_macros.rst index 7e118ec8..10582ee8 100644 --- a/docs/logging_macros.rst +++ b/docs/logging_macros.rst @@ -36,6 +36,8 @@ Standard Logging Macros - :c:macro:`LOG_TRACE_L3_LIMIT(min_interval, logger, fmt, ...)` +- :c:macro:`LOG_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...)` + - :c:macro:`LOG_TRACE_L3_TAGS(logger, tags, fmt, ...)` **Trace Level 2 (L2)** @@ -44,6 +46,8 @@ Standard Logging Macros - :c:macro:`LOG_TRACE_L2_LIMIT(min_interval, logger, fmt, ...)` +- :c:macro:`LOG_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...)` + - :c:macro:`LOG_TRACE_L2_TAGS(logger, tags, fmt, ...)` **Trace Level 1 (L1)** @@ -52,6 +56,8 @@ Standard Logging Macros - :c:macro:`LOG_TRACE_L1_LIMIT(min_interval, logger, fmt, ...)` +- :c:macro:`LOG_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...)` + - :c:macro:`LOG_TRACE_L1_TAGS(logger, tags, fmt, ...)` **Debug** @@ -60,6 +66,8 @@ Standard Logging Macros - :c:macro:`LOG_DEBUG_LIMIT(min_interval, logger, fmt, ...)` +- :c:macro:`LOG_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...)` + - :c:macro:`LOG_DEBUG_TAGS(logger, tags, fmt, ...)` **Info** @@ -68,6 +76,8 @@ Standard Logging Macros - :c:macro:`LOG_INFO_LIMIT(min_interval, logger, fmt, ...)` +- :c:macro:`LOG_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...)` + - :c:macro:`LOG_INFO_TAGS(logger, tags, fmt, ...)` **Notice** @@ -76,6 +86,8 @@ Standard Logging Macros - :c:macro:`LOG_NOTICE_LIMIT(min_interval, logger, fmt, ...)` +- :c:macro:`LOG_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...)` + - :c:macro:`LOG_NOTICE_TAGS(logger, tags, fmt, ...)` **Warning** @@ -84,6 +96,8 @@ Standard Logging Macros - :c:macro:`LOG_WARNING_LIMIT(min_interval, logger, fmt, ...)` +- :c:macro:`LOG_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...)` + - :c:macro:`LOG_WARNING_TAGS(logger, tags, fmt, ...)` **Error** @@ -92,6 +106,8 @@ Standard Logging Macros - :c:macro:`LOG_ERROR_LIMIT(min_interval, logger, fmt, ...)` +- :c:macro:`LOG_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...)` + - :c:macro:`LOG_ERROR_TAGS(logger, tags, fmt, ...)` **Critical** @@ -100,6 +116,8 @@ Standard Logging Macros - :c:macro:`LOG_CRITICAL_LIMIT(min_interval, logger, fmt, ...)` +- :c:macro:`LOG_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...)` + - :c:macro:`LOG_CRITICAL_TAGS(logger, tags, fmt, ...)` **Backtrace** @@ -118,6 +136,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGV_TRACE_L3_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGV_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGV_TRACE_L3_TAGS(logger, tags, message, ...)` **Trace Level 2 (L2)** @@ -126,6 +146,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGV_TRACE_L2_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGV_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGV_TRACE_L2_TAGS(logger, tags, message, ...)` **Trace Level 1 (L1)** @@ -134,6 +156,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGV_TRACE_L1_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGV_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGV_TRACE_L1_TAGS(logger, tags, message, ...)` **Debug** @@ -142,6 +166,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGV_DEBUG_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGV_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGV_DEBUG_TAGS(logger, tags, message, ...)` **Info** @@ -150,6 +176,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGV_INFO_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGV_INFO_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGV_INFO_TAGS(logger, tags, message, ...)` **Notice** @@ -158,6 +186,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGV_NOTICE_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGV_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGV_NOTICE_TAGS(logger, tags, message, ...)` **Warning** @@ -166,6 +196,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGV_WARNING_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGV_WARNING_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGV_WARNING_TAGS(logger, tags, message, ...)` **Error** @@ -174,6 +206,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGV_ERROR_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGV_ERROR_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGV_ERROR_TAGS(logger, tags, message, ...)` **Critical** @@ -182,6 +216,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGV_CRITICAL_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGV_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGV_CRITICAL_TAGS(logger, tags, message, ...)` **Backtrace** @@ -200,6 +236,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGJ_TRACE_L3_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGJ_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGJ_TRACE_L3_TAGS(logger, tags, message, ...)` **Trace Level 2 (L2)** @@ -208,6 +246,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGJ_TRACE_L2_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGJ_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGJ_TRACE_L2_TAGS(logger, tags, message, ...)` **Trace Level 1 (L1)** @@ -216,6 +256,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGJ_TRACE_L1_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGJ_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGJ_TRACE_L1_TAGS(logger, tags, message, ...)` **Debug** @@ -224,6 +266,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGJ_DEBUG_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGJ_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGJ_DEBUG_TAGS(logger, tags, message, ...)` **Info** @@ -232,6 +276,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGJ_INFO_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGJ_INFO_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGJ_INFO_TAGS(logger, tags, message, ...)` **Notice** @@ -240,6 +286,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGJ_NOTICE_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGJ_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGJ_NOTICE_TAGS(logger, tags, message, ...)` **Warning** @@ -248,6 +296,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGJ_WARNING_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGJ_WARNING_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGJ_WARNING_TAGS(logger, tags, message, ...)` **Error** @@ -256,6 +306,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGJ_ERROR_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGJ_ERROR_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGJ_ERROR_TAGS(logger, tags, message, ...)` **Critical** @@ -264,6 +316,8 @@ Each macro can handle up to 26 arguments. The format string is concatenated at c - :c:macro:`LOGJ_CRITICAL_LIMIT(min_interval, logger, message, ...)` +- :c:macro:`LOGJ_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, message, ...)` + - :c:macro:`LOGJ_CRITICAL_TAGS(logger, tags, message, ...)` **Backtrace** diff --git a/examples/console_logging.cpp b/examples/console_logging.cpp index 136a608e..8f9053c4 100644 --- a/examples/console_logging.cpp +++ b/examples/console_logging.cpp @@ -52,10 +52,22 @@ int main() double b = 3.17; LOGV_NOTICE(logger, "A message with two variables", a, b); - for (uint32_t i = 0; i < 10; ++i) + for (uint32_t i = 0; i < 40; ++i) { // Will only log the message once per second LOG_INFO_LIMIT(std::chrono::seconds{1}, logger, "A {} message with number {}", l, a); LOGV_INFO_LIMIT(std::chrono::seconds{1}, logger, "A message with two variables", a, b); + + if (i % 10 == 0) + { + std::this_thread::sleep_for(std::chrono::milliseconds{(i / 10) * 500}); + } + } + + for (uint32_t i = 0; i < 20; ++i) + { + // Will only log the message once per N occurrences second + LOG_INFO_LIMIT_EVERY_N(10, logger, "Another {} message with occurrence {}", l, i); + LOGV_INFO_LIMIT_EVERY_N(10, logger, "Another message with two variables", a, i); } } diff --git a/examples/json_console_logging.cpp b/examples/json_console_logging.cpp index c548e263..1cb0420f 100644 --- a/examples/json_console_logging.cpp +++ b/examples/json_console_logging.cpp @@ -30,4 +30,23 @@ int main() // Or manually specify the desired names of each variable LOG_INFO(logger, "A json message with {var_1} and {var_2}", var_a, var_b); + + for (uint32_t i = 0; i < 40; ++i) + { + // Will only log the message once per second + LOG_INFO_LIMIT(std::chrono::seconds{1}, logger, "A json message with {var_1} and {var_2}", var_a, var_b); + LOGJ_INFO_LIMIT(std::chrono::seconds{1}, logger, "A json message", var_a, var_b); + + if (i % 10 == 0) + { + std::this_thread::sleep_for(std::chrono::milliseconds{(i / 10) * 500}); + } + } + + for (uint32_t i = 0; i < 20; ++i) + { + // Will only log the message once per N occurrences second + LOG_INFO_LIMIT_EVERY_N(10, logger, "A json message with {var_1} and {occurrence}", var_a, i); + LOGJ_INFO_LIMIT_EVERY_N(10, logger, "A json message", var_a, i); + } } diff --git a/include/quill/LogMacros.h b/include/quill/LogMacros.h index da4f9cc9..7e7dc7f7 100644 --- a/include/quill/LogMacros.h +++ b/include/quill/LogMacros.h @@ -302,15 +302,15 @@ quill::MacroMetadata::Event::Log \ } -#define QUILL_LOGGER_CALL(likelyhood, logger, tags, log_level, fmt, ...) \ - do \ - { \ - if (likelyhood(logger->template should_log_statement())) \ - { \ +#define QUILL_LOGGER_CALL(likelyhood, logger, tags, log_level, fmt, ...) \ + do \ + { \ + if (likelyhood(logger->template should_log_statement())) \ + { \ QUILL_DEFINE_MACRO_METADATA(__FUNCTION__, fmt, tags, log_level); \ logger->template log_statement( \ quill::LogLevel::None, ¯o_metadata, ##__VA_ARGS__); \ - } \ + } \ } while (0) #define QUILL_LOGGER_CALL_LIMIT(min_interval, likelyhood, logger, tags, log_level, fmt, ...) \ @@ -319,41 +319,73 @@ if (likelyhood(logger->template should_log_statement())) \ { \ thread_local std::chrono::time_point next_log_time; \ + thread_local uint64_t suppressed_log_count{0}; \ auto const now = std::chrono::steady_clock::now(); \ \ if (now < next_log_time) \ { \ + ++suppressed_log_count; \ break; \ } \ \ + if constexpr (quill::MacroMetadata::_contains_named_args(fmt)) \ + { \ + QUILL_LOGGER_CALL(likelyhood, logger, tags, log_level, fmt " ({occurred}x)", \ + ##__VA_ARGS__, suppressed_log_count + 1); \ + } \ + else \ + { \ + QUILL_LOGGER_CALL(likelyhood, logger, tags, log_level, fmt " ({}x)", ##__VA_ARGS__, \ + suppressed_log_count + 1); \ + } \ + \ next_log_time = now + min_interval; \ - QUILL_LOGGER_CALL(likelyhood, logger, tags, log_level, fmt, ##__VA_ARGS__); \ + suppressed_log_count = 0; \ } \ } while (0) -#define QUILL_BACKTRACE_LOGGER_CALL(logger, tags, fmt, ...) \ - do \ - { \ - if (QUILL_LIKELY(logger->template should_log_statement())) \ - { \ +#define QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, likelyhood, logger, tags, log_level, fmt, ...) \ + do \ + { \ + if (likelyhood(logger->template should_log_statement())) \ + { \ + thread_local uint64_t occurrences{0}; \ + \ + if (occurrences >= n_occurrences - 1) \ + { \ + QUILL_LOGGER_CALL(likelyhood, logger, tags, log_level, fmt, ##__VA_ARGS__); \ + occurrences = 0; \ + } \ + else \ + { \ + ++occurrences; \ + } \ + } \ + } while (0) + +#define QUILL_BACKTRACE_LOGGER_CALL(logger, tags, fmt, ...) \ + do \ + { \ + if (QUILL_LIKELY(logger->template should_log_statement())) \ + { \ QUILL_DEFINE_MACRO_METADATA(__FUNCTION__, fmt, tags, quill::LogLevel::Backtrace); \ logger->template log_statement( \ quill::LogLevel::None, ¯o_metadata, ##__VA_ARGS__); \ - } \ + } \ } while (0) /** * Dynamic runtime log level with a tiny overhead * @Note: Prefer using the compile time log level macros */ -#define QUILL_DYNAMIC_LOGGER_CALL(logger, tags, log_level, fmt, ...) \ - do \ - { \ - if (logger->should_log_statement(log_level)) \ - { \ +#define QUILL_DYNAMIC_LOGGER_CALL(logger, tags, log_level, fmt, ...) \ + do \ + { \ + if (logger->should_log_statement(log_level)) \ + { \ QUILL_DEFINE_MACRO_METADATA(__FUNCTION__, fmt, tags, quill::LogLevel::Dynamic); \ logger->template log_statement(log_level, ¯o_metadata, ##__VA_ARGS__); \ - } \ + } \ } while (0) #if QUILL_COMPILE_ACTIVE_LOG_LEVEL <= QUILL_COMPILE_ACTIVE_LOG_LEVEL_TRACE_L3 @@ -364,6 +396,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, \ quill::LogLevel::TraceL3, fmt, ##__VA_ARGS__) + #define QUILL_LOG_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, \ + quill::LogLevel::TraceL3, fmt, ##__VA_ARGS__) + #define QUILL_LOG_TRACE_L3_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::TraceL3, fmt, ##__VA_ARGS__) @@ -375,6 +411,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL3, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL3, \ + QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_TRACE_L3_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::TraceL3, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) @@ -387,18 +427,25 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL3, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL3, \ + QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_TRACE_L3_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::TraceL3, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) #else #define QUILL_LOG_TRACE_L3(logger, fmt, ...) (void)0 #define QUILL_LOG_TRACE_L3_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOG_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOG_TRACE_L3_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGV_TRACE_L3(logger, fmt, ...) (void)0 #define QUILL_LOGV_TRACE_L3_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGV_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGV_TRACE_L3_TAGS (void)0 #define QUILL_LOGJ_TRACE_L3(logger, fmt, ...) (void)0 #define QUILL_LOGJ_TRACE_L3_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGJ_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGJ_TRACE_L3_TAGS (void)0 #endif @@ -410,6 +457,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, \ quill::LogLevel::TraceL2, fmt, ##__VA_ARGS__) + #define QUILL_LOG_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, \ + quill::LogLevel::TraceL2, fmt, ##__VA_ARGS__) + #define QUILL_LOG_TRACE_L2_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::TraceL2, fmt, ##__VA_ARGS__) @@ -421,6 +472,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL2, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL2, \ + QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_TRACE_L2_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::TraceL2, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) @@ -433,18 +488,25 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL2, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL2, \ + QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_TRACE_L2_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::TraceL2, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) #else #define QUILL_LOG_TRACE_L2(logger, fmt, ...) (void)0 #define QUILL_LOG_TRACE_L2_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOG_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOG_TRACE_L2_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGV_TRACE_L2(logger, fmt, ...) (void)0 #define QUILL_LOGV_TRACE_L2_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGV_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGV_TRACE_L2_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGJ_TRACE_L2(logger, fmt, ...) (void)0 #define QUILL_LOGJ_TRACE_L2_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGJ_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGJ_TRACE_L2_TAGS(logger, tags, fmt, ...) (void)0 #endif @@ -456,6 +518,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, \ quill::LogLevel::TraceL1, fmt, ##__VA_ARGS__) + #define QUILL_LOG_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, \ + quill::LogLevel::TraceL1, fmt, ##__VA_ARGS__) + #define QUILL_LOG_TRACE_L1_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::TraceL1, fmt, ##__VA_ARGS__) @@ -467,6 +533,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL1, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL1, \ + QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_TRACE_L1_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::TraceL1, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) @@ -479,18 +549,25 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL1, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::TraceL1, \ + QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_TRACE_L1_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::TraceL1, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) #else #define QUILL_LOG_TRACE_L1(logger, fmt, ...) (void)0 #define QUILL_LOG_TRACE_L1_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOG_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOG_TRACE_L1_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGV_TRACE_L1(logger, fmt, ...) (void)0 #define QUILL_LOGV_TRACE_L1_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGV_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGV_TRACE_L1_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGJ_TRACE_L1(logger, fmt, ...) (void)0 #define QUILL_LOGJ_TRACE_L1_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGJ_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGJ_TRACE_L1_TAGS(logger, tags, fmt, ...) (void)0 #endif @@ -501,6 +578,10 @@ #define QUILL_LOG_DEBUG_LIMIT(min_interval, logger, fmt, ...) \ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::Debug, fmt, ##__VA_ARGS__) + #define QUILL_LOG_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, \ + quill::LogLevel::Debug, fmt, ##__VA_ARGS__) + #define QUILL_LOG_DEBUG_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::Debug, fmt, ##__VA_ARGS__) @@ -512,6 +593,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::Debug, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::Debug, \ + QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_DEBUG_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::Debug, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) @@ -524,18 +609,25 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::Debug, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_UNLIKELY, logger, nullptr, quill::LogLevel::Debug, \ + QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_DEBUG_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_UNLIKELY, logger, tags, quill::LogLevel::Debug, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) #else #define QUILL_LOG_DEBUG(logger, fmt, ...) (void)0 #define QUILL_LOG_DEBUG_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOG_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOG_DEBUG_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGV_DEBUG(logger, fmt, ...) (void)0 #define QUILL_LOGV_DEBUG_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGV_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGV_DEBUG_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGJ_DEBUG(logger, fmt, ...) (void)0 #define QUILL_LOGJ_DEBUG_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGJ_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGJ_DEBUG_TAGS(logger, tags, fmt, ...) (void)0 #endif @@ -546,6 +638,10 @@ #define QUILL_LOG_INFO_LIMIT(min_interval, logger, fmt, ...) \ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Info, fmt, ##__VA_ARGS__) + #define QUILL_LOG_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, \ + quill::LogLevel::Info, fmt, ##__VA_ARGS__) + #define QUILL_LOG_INFO_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Info, fmt, ##__VA_ARGS__) @@ -557,6 +653,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Info, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Info, \ + QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_INFO_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Info, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) @@ -569,63 +669,85 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Info, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Info, \ + QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_INFO_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Info, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) #else #define QUILL_LOG_INFO(logger, fmt, ...) (void)0 #define QUILL_LOG_INFO_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOG_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOG_INFO_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGV_INFO(logger, fmt, ...) (void)0 #define QUILL_LOGV_INFO_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGV_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGV_INFO_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGJ_INFO(logger, fmt, ...) (void)0 #define QUILL_LOGJ_INFO_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGJ_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGJ_INFO_TAGS(logger, tags, fmt, ...) (void)0 #endif #if QUILL_COMPILE_ACTIVE_LOG_LEVEL <= QUILL_COMPILE_ACTIVE_LOG_LEVEL_NOTICE - #define QUILL_LOG_NOTICE(logger, fmt, ...) \ + #define QUILL_LOG_NOTICE(logger, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, fmt, ##__VA_ARGS__) - #define QUILL_LOG_NOTICE_LIMIT(min_interval, logger, fmt, ...) \ + #define QUILL_LOG_NOTICE_LIMIT(min_interval, logger, fmt, ...) \ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, fmt, ##__VA_ARGS__) - #define QUILL_LOG_NOTICE_TAGS(logger, tags, fmt, ...) \ + #define QUILL_LOG_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, \ + quill::LogLevel::Notice, fmt, ##__VA_ARGS__) + + #define QUILL_LOG_NOTICE_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Notice, fmt, ##__VA_ARGS__) - #define QUILL_LOGV_NOTICE(logger, fmt, ...) \ - QUILL_LOGGER_CALL(QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \ + #define QUILL_LOGV_NOTICE(logger, fmt, ...) \ + QUILL_LOGGER_CALL(QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) - #define QUILL_LOGV_NOTICE_LIMIT(min_interval, logger, fmt, ...) \ - QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \ + #define QUILL_LOGV_NOTICE_LIMIT(min_interval, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) - #define QUILL_LOGV_NOTICE_TAGS(logger, tags, fmt, ...) \ - QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Notice, \ + #define QUILL_LOGV_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \ + QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + + #define QUILL_LOGV_NOTICE_TAGS(logger, tags, fmt, ...) \ + QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Notice, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) - #define QUILL_LOGJ_NOTICE(logger, fmt, ...) \ - QUILL_LOGGER_CALL(QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \ + #define QUILL_LOGJ_NOTICE(logger, fmt, ...) \ + QUILL_LOGGER_CALL(QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) - #define QUILL_LOGJ_NOTICE_LIMIT(min_interval, logger, fmt, ...) \ - QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \ + #define QUILL_LOGJ_NOTICE_LIMIT(min_interval, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) - #define QUILL_LOGJ_NOTICE_TAGS(logger, tags, fmt, ...) \ - QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Notice, \ + #define QUILL_LOGJ_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Notice, \ + QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + + #define QUILL_LOGJ_NOTICE_TAGS(logger, tags, fmt, ...) \ + QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Notice, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) #else #define QUILL_LOG_NOTICE(logger, fmt, ...) (void)0 #define QUILL_LOG_NOTICE_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOG_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOG_NOTICE_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGV_NOTICE(logger, fmt, ...) (void)0 #define QUILL_LOGV_NOTICE_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGV_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGV_NOTICE_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGJ_NOTICE(logger, fmt, ...) (void)0 #define QUILL_LOGJ_NOTICE_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGJ_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGJ_NOTICE_TAGS(logger, tags, fmt, ...) (void)0 #endif @@ -636,6 +758,10 @@ #define QUILL_LOG_WARNING_LIMIT(min_interval, logger, fmt, ...) \ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Warning, fmt, ##__VA_ARGS__) + #define QUILL_LOG_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, \ + quill::LogLevel::Warning, fmt, ##__VA_ARGS__) + #define QUILL_LOG_WARNING_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Warning, fmt, ##__VA_ARGS__) @@ -647,6 +773,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Warning, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Warning, \ + QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_WARNING_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Warning, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) @@ -659,18 +789,25 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Warning, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Warning, \ + QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_WARNING_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Warning, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) #else #define QUILL_LOG_WARNING(logger, fmt, ...) (void)0 #define QUILL_LOG_WARNING_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOG_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOG_WARNING_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGV_WARNING(logger, fmt, ...) (void)0 #define QUILL_LOGV_WARNING_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGV_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGV_WARNING_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGJ_WARNING(logger, fmt, ...) (void)0 #define QUILL_LOGJ_WARNING_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGJ_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGJ_WARNING_TAGS(logger, tags, fmt, ...) (void)0 #endif @@ -681,6 +818,10 @@ #define QUILL_LOG_ERROR_LIMIT(min_interval, logger, fmt, ...) \ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Error, fmt, ##__VA_ARGS__) + #define QUILL_LOG_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, \ + quill::LogLevel::Error, fmt, ##__VA_ARGS__) + #define QUILL_LOG_ERROR_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Error, fmt, ##__VA_ARGS__) @@ -692,6 +833,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Error, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Error, \ + QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_ERROR_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Error, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) @@ -704,18 +849,25 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Error, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Error, \ + QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_ERROR_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Error, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) #else #define QUILL_LOG_ERROR(logger, fmt, ...) (void)0 #define QUILL_LOG_ERROR_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOG_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOG_ERROR_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGV_ERROR(logger, fmt, ...) (void)0 #define QUILL_LOGV_ERROR_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGV_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGV_ERROR_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGJ_ERROR(logger, fmt, ...) (void)0 #define QUILL_LOGJ_ERROR_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGJ_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGJ_ERROR_TAGS(logger, tags, fmt, ...) (void)0 #endif @@ -727,6 +879,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, \ quill::LogLevel::Critical, fmt, ##__VA_ARGS__) + #define QUILL_LOG_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, \ + quill::LogLevel::Critical, fmt, ##__VA_ARGS__) + #define QUILL_LOG_CRITICAL_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Critical, fmt, ##__VA_ARGS__) @@ -738,6 +894,10 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Critical, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Critical, \ + QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGV_CRITICAL_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Critical, \ QUILL_GENERATE_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) @@ -750,18 +910,25 @@ QUILL_LOGGER_CALL_LIMIT(min_interval, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Critical, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGGER_CALL_LIMIT_EVERY_N(n_occurrences, QUILL_LIKELY, logger, nullptr, quill::LogLevel::Critical, \ + QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) + #define QUILL_LOGJ_CRITICAL_TAGS(logger, tags, fmt, ...) \ QUILL_LOGGER_CALL(QUILL_LIKELY, logger, tags, quill::LogLevel::Critical, \ QUILL_GENERATE_NAMED_FORMAT_STRING(fmt, ##__VA_ARGS__), ##__VA_ARGS__) #else #define QUILL_LOG_CRITICAL(logger, fmt, ...) (void)0 #define QUILL_LOG_CRITICAL_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOG_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOG_CRITICAL_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGV_CRITICAL(logger, fmt, ...) (void)0 #define QUILL_LOGV_CRITICAL_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGV_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGV_CRITICAL_TAGS(logger, tags, fmt, ...) (void)0 #define QUILL_LOGJ_CRITICAL(logger, fmt, ...) (void)0 #define QUILL_LOGJ_CRITICAL_LIMIT(min_interval, logger, fmt, ...) (void)0 + #define QUILL_LOGJ_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) (void)0 #define QUILL_LOGJ_CRITICAL_TAGS(logger, tags, fmt, ...) (void)0 #endif @@ -825,6 +992,25 @@ #define LOG_CRITICAL_LIMIT(min_interval, logger, fmt, ...) \ QUILL_LOG_CRITICAL_LIMIT(min_interval, logger, fmt, ##__VA_ARGS__) + #define LOG_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOG_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOG_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOG_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOG_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOG_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOG_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOG_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOG_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOG_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOG_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOG_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOG_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOG_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOG_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOG_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOG_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOG_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOG_TRACE_L3_TAGS(logger, tags, fmt, ...) \ QUILL_LOG_TRACE_L3_TAGS(logger, tags, fmt, ##__VA_ARGS__) #define LOG_TRACE_L2_TAGS(logger, tags, fmt, ...) \ @@ -880,6 +1066,25 @@ #define LOGV_CRITICAL_LIMIT(min_interval, logger, fmt, ...) \ QUILL_LOGV_CRITICAL_LIMIT(min_interval, logger, fmt, ##__VA_ARGS__) + #define LOGV_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGV_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGV_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGV_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGV_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGV_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGV_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGV_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGV_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGV_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGV_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGV_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGV_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGV_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGV_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGV_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGV_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGV_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGV_TRACE_L3_TAGS(logger, tags, fmt, ...) \ QUILL_LOGV_TRACE_L3_TAGS(logger, tags, fmt, ##__VA_ARGS__) #define LOGV_TRACE_L2_TAGS(logger, tags, fmt, ...) \ @@ -931,6 +1136,25 @@ #define LOGJ_CRITICAL_LIMIT(min_interval, logger, fmt, ...) \ QUILL_LOGJ_CRITICAL_LIMIT(min_interval, logger, fmt, ##__VA_ARGS__) + #define LOGJ_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGJ_TRACE_L3_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGJ_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGJ_TRACE_L2_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGJ_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGJ_TRACE_L1_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGJ_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGJ_DEBUG_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGJ_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGJ_INFO_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGJ_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGJ_NOTICE_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGJ_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGJ_WARNING_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGJ_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGJ_ERROR_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGJ_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ...) \ + QUILL_LOGJ_CRITICAL_LIMIT_EVERY_N(n_occurrences, logger, fmt, ##__VA_ARGS__) + #define LOGJ_TRACE_L3_TAGS(logger, tags, fmt, ...) \ QUILL_LOGJ_TRACE_L3_TAGS(logger, tags, fmt, ##__VA_ARGS__) #define LOGJ_TRACE_L2_TAGS(logger, tags, fmt, ...) \ diff --git a/include/quill/core/MacroMetadata.h b/include/quill/core/MacroMetadata.h index 034d22ce..bc3faef5 100644 --- a/include/quill/core/MacroMetadata.h +++ b/include/quill/core/MacroMetadata.h @@ -80,46 +80,8 @@ class MacroMetadata QUILL_NODISCARD Event event() const noexcept { return _event; } -private: - /***/ - QUILL_NODISCARD constexpr uint16_t _calc_file_name_pos() const noexcept - { - char const* source_location = _source_location; - char const* file = source_location; - while (*source_location) - { - char cur = *source_location++; - if (cur == '/' || cur == PATH_PREFERRED_SEPARATOR) - { - file = source_location; - } - } - return static_cast(file - _source_location); - } - - /***/ - QUILL_NODISCARD constexpr uint16_t _calc_colon_separator_pos() const noexcept - { - std::string_view const source_loc{_source_location}; - auto const separator_index = source_loc.rfind(':'); - return static_cast(separator_index); - } - - /***/ - constexpr void _set_named_args_flag(bool value) noexcept - { - if (value) - { - _format_flags |= NAMED_ARGS_FLAG; - } - else - { - _format_flags &= static_cast(~NAMED_ARGS_FLAG); - } - } - /***/ - static constexpr bool _contains_named_args(std::string_view fmt) noexcept + QUILL_NODISCARD static constexpr bool _contains_named_args(std::string_view fmt) noexcept { uint32_t pos{0}; bool found_named_arg{false}; @@ -183,6 +145,44 @@ class MacroMetadata return found_named_arg; } +private: + /***/ + QUILL_NODISCARD constexpr uint16_t _calc_file_name_pos() const noexcept + { + char const* source_location = _source_location; + char const* file = source_location; + while (*source_location) + { + char cur = *source_location++; + if (cur == '/' || cur == PATH_PREFERRED_SEPARATOR) + { + file = source_location; + } + } + return static_cast(file - _source_location); + } + + /***/ + QUILL_NODISCARD constexpr uint16_t _calc_colon_separator_pos() const noexcept + { + std::string_view const source_loc{_source_location}; + auto const separator_index = source_loc.rfind(':'); + return static_cast(separator_index); + } + + /***/ + constexpr void _set_named_args_flag(bool value) noexcept + { + if (value) + { + _format_flags |= NAMED_ARGS_FLAG; + } + else + { + _format_flags &= static_cast(~NAMED_ARGS_FLAG); + } + } + private: // define our own PATH_PREFERRED_SEPARATOR to not include #if defined(_WIN32) && !defined(__CYGWIN__) diff --git a/test/integration_tests/MacrosTest.cpp b/test/integration_tests/MacrosTest.cpp index ca62d06d..571221b4 100644 --- a/test/integration_tests/MacrosTest.cpp +++ b/test/integration_tests/MacrosTest.cpp @@ -63,6 +63,16 @@ TEST_CASE("macros") LOG_ERROR_LIMIT(std::chrono::nanoseconds{0}, logger, "B ERR: {}", 60.78); LOG_CRITICAL_LIMIT(std::chrono::nanoseconds{0}, logger, "B CRT: {}", -10); + LOG_TRACE_L3_LIMIT_EVERY_N(1, logger, "BA L3: {}", 10); + LOG_TRACE_L2_LIMIT_EVERY_N(1, logger, "BA L2: {}", 20); + LOG_TRACE_L1_LIMIT_EVERY_N(1, logger, "BA L1: {}", 30); + LOG_DEBUG_LIMIT_EVERY_N(1, logger, "BA DBG: {}", 40); + LOG_INFO_LIMIT_EVERY_N(1, logger, "BA INF: {}", 50); + LOG_NOTICE_LIMIT_EVERY_N(1, logger, "BA NTC: {}", "Notice"); + LOG_WARNING_LIMIT_EVERY_N(1, logger, "BA WRN: {}", "Warning"); + LOG_ERROR_LIMIT_EVERY_N(1, logger, "BA ERR: {}", 60.78); + LOG_CRITICAL_LIMIT_EVERY_N(1, logger, "BA CRT: {}", -10); + LOG_TRACE_L3_TAGS(logger, TAGS("tag"), "C L3: {}", 100); LOG_TRACE_L2_TAGS(logger, TAGS("tag"), "C L2: {}", 200); LOG_TRACE_L1_TAGS(logger, TAGS("tag"), "C L1: {}", 300); @@ -98,6 +108,16 @@ TEST_CASE("macros") LOGV_ERROR_LIMIT(std::chrono::nanoseconds{0}, logger, "E ERR", var); LOGV_CRITICAL_LIMIT(std::chrono::nanoseconds{0}, logger, "E CRT", var); + LOGV_TRACE_L3_LIMIT_EVERY_N(1, logger, "EA L3", var); + LOGV_TRACE_L2_LIMIT_EVERY_N(1, logger, "EA L2", var); + LOGV_TRACE_L1_LIMIT_EVERY_N(1, logger, "EA L1", var); + LOGV_DEBUG_LIMIT_EVERY_N(1, logger, "EA DBG", var); + LOGV_INFO_LIMIT_EVERY_N(1, logger, "EA INF", var); + LOGV_NOTICE_LIMIT_EVERY_N(1, logger, "EA NTC", var); + LOGV_WARNING_LIMIT_EVERY_N(1, logger, "EA WRN", var); + LOGV_ERROR_LIMIT_EVERY_N(1, logger, "EA ERR", var); + LOGV_CRITICAL_LIMIT_EVERY_N(1, logger, "EA CRT", var); + LOGV_TRACE_L3_TAGS(logger, TAGS("tag"), "F L3", var); LOGV_TRACE_L2_TAGS(logger, TAGS("tag"), "F L2", var); LOGV_TRACE_L1_TAGS(logger, TAGS("tag"), "F L1", var); @@ -130,6 +150,16 @@ TEST_CASE("macros") LOGJ_ERROR_LIMIT(std::chrono::nanoseconds{0}, logger, "H ERR", var); LOGJ_CRITICAL_LIMIT(std::chrono::nanoseconds{0}, logger, "H CRT", var); + LOGJ_TRACE_L3_LIMIT_EVERY_N(1, logger, "HA L3", var); + LOGJ_TRACE_L2_LIMIT_EVERY_N(1, logger, "HA L2", var); + LOGJ_TRACE_L1_LIMIT_EVERY_N(1, logger, "HA L1", var); + LOGJ_DEBUG_LIMIT_EVERY_N(1, logger, "HA DBG", var); + LOGJ_INFO_LIMIT_EVERY_N(1, logger, "HA INF", var); + LOGJ_NOTICE_LIMIT_EVERY_N(1, logger, "HA NTC", var); + LOGJ_WARNING_LIMIT_EVERY_N(1, logger, "HA WRN", var); + LOGJ_ERROR_LIMIT_EVERY_N(1, logger, "HA ERR", var); + LOGJ_CRITICAL_LIMIT_EVERY_N(1, logger, "HA CRT", var); + LOGJ_TRACE_L3_TAGS(logger, TAGS("tag"), "K L3", var); LOGJ_TRACE_L2_TAGS(logger, TAGS("tag"), "K L2", var); LOGJ_TRACE_L1_TAGS(logger, TAGS("tag"), "K L1", var); @@ -160,15 +190,28 @@ TEST_CASE("macros") REQUIRE(quill::testing::file_contains(file_contents, std::string{"C LOG_CRITICAL logger DYN: 42"})); REQUIRE(quill::testing::file_contains(file_contents, std::string{"BT LOG_BACKTRACE logger BT: 255"})); - REQUIRE(quill::testing::file_contains(file_contents, std::string{"T3 LOG_TRACE_L3 logger B L3: 10"})); - REQUIRE(quill::testing::file_contains(file_contents, std::string{"T2 LOG_TRACE_L2 logger B L2: 20"})); - REQUIRE(quill::testing::file_contains(file_contents, std::string{"T1 LOG_TRACE_L1 logger B L1: 30"})); - REQUIRE(quill::testing::file_contains(file_contents, std::string{"D LOG_DEBUG logger B DBG: 40"})); - REQUIRE(quill::testing::file_contains(file_contents, std::string{"I LOG_INFO logger B INF: 50"})); - REQUIRE(quill::testing::file_contains(file_contents, std::string{"N LOG_NOTICE logger B NTC: Notice"})); - REQUIRE(quill::testing::file_contains(file_contents, std::string{"W LOG_WARNING logger B WRN: Warning"})); - REQUIRE(quill::testing::file_contains(file_contents, std::string{"E LOG_ERROR logger B ERR: 60.78"})); - REQUIRE(quill::testing::file_contains(file_contents, std::string{"C LOG_CRITICAL logger B CRT: -10"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"T3 LOG_TRACE_L3 logger B L3: 10 (1x)"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"T2 LOG_TRACE_L2 logger B L2: 20 (1x)"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"T1 LOG_TRACE_L1 logger B L1: 30 (1x)"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"D LOG_DEBUG logger B DBG: 40 (1x)"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"I LOG_INFO logger B INF: 50 (1x)"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"N LOG_NOTICE logger B NTC: Notice (1x)"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"W LOG_WARNING logger B WRN: Warning (1x)"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"E LOG_ERROR logger B ERR: 60.78 (1x)"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"C LOG_CRITICAL logger B CRT: -10 (1x)"})); + + REQUIRE(quill::testing::file_contains(file_contents, std::string{"T3 LOG_TRACE_L3 logger BA L3: 10"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"T2 LOG_TRACE_L2 logger BA L2: 20"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"T1 LOG_TRACE_L1 logger BA L1: 30"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"D LOG_DEBUG logger BA DBG: 40"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"I LOG_INFO logger BA INF: 50"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"N LOG_NOTICE logger BA NTC: Notice"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"W LOG_WARNING logger BA WRN: Warning"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"E LOG_ERROR logger BA ERR: 60.78"})); + REQUIRE(quill::testing::file_contains(file_contents, std::string{"C LOG_CRITICAL logger BA CRT: -10"})); REQUIRE(quill::testing::file_contains( file_contents, std::string{"T3 LOG_TRACE_L3 logger C L3: 100 [ #tag ]"})); @@ -217,23 +260,42 @@ TEST_CASE("macros") file_contents, std::string{"BT LOG_BACKTRACE logger D BT [var: 1337]"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"T3 LOG_TRACE_L3 logger E L3 [var: 1337]"})); + file_contents, std::string{"T3 LOG_TRACE_L3 logger E L3 [var: 1337] (1x)"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"T2 LOG_TRACE_L2 logger E L2 [var: 1337]"})); + file_contents, std::string{"T2 LOG_TRACE_L2 logger E L2 [var: 1337] (1x)"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"T1 LOG_TRACE_L1 logger E L1 [var: 1337]"})); + file_contents, std::string{"T1 LOG_TRACE_L1 logger E L1 [var: 1337] (1x)"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"D LOG_DEBUG logger E DBG [var: 1337]"})); + file_contents, std::string{"D LOG_DEBUG logger E DBG [var: 1337] (1x)"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"I LOG_INFO logger E INF [var: 1337]"})); + file_contents, std::string{"I LOG_INFO logger E INF [var: 1337] (1x)"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"N LOG_NOTICE logger E NTC [var: 1337]"})); + file_contents, std::string{"N LOG_NOTICE logger E NTC [var: 1337] (1x)"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"W LOG_WARNING logger E WRN [var: 1337]"})); + file_contents, std::string{"W LOG_WARNING logger E WRN [var: 1337] (1x)"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"E LOG_ERROR logger E ERR [var: 1337]"})); + file_contents, std::string{"E LOG_ERROR logger E ERR [var: 1337] (1x)"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"C LOG_CRITICAL logger E CRT [var: 1337]"})); + file_contents, std::string{"C LOG_CRITICAL logger E CRT [var: 1337] (1x)"})); + + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"T3 LOG_TRACE_L3 logger EA L3 [var: 1337]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"T2 LOG_TRACE_L2 logger EA L2 [var: 1337]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"T1 LOG_TRACE_L1 logger EA L1 [var: 1337]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"D LOG_DEBUG logger EA DBG [var: 1337]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"I LOG_INFO logger EA INF [var: 1337]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"N LOG_NOTICE logger EA NTC [var: 1337]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"W LOG_WARNING logger EA WRN [var: 1337]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"E LOG_ERROR logger EA ERR [var: 1337]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"C LOG_CRITICAL logger EA CRT [var: 1337]"})); REQUIRE(quill::testing::file_contains( file_contents, std::string{"T3 LOG_TRACE_L3 logger F L3 [var: 1337] [ #tag ]"})); @@ -278,23 +340,42 @@ TEST_CASE("macros") file_contents, std::string{"BT LOG_BACKTRACE logger G BT 1337 [ ] [var: 1337]"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"T3 LOG_TRACE_L3 logger H L3 1337 [ ] [var: 1337]"})); + file_contents, std::string{"T3 LOG_TRACE_L3 logger H L3 1337 (1x) [ ] [var: 1337, occurred: 1]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"T2 LOG_TRACE_L2 logger H L2 1337 (1x) [ ] [var: 1337, occurred: 1]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"T1 LOG_TRACE_L1 logger H L1 1337 (1x) [ ] [var: 1337, occurred: 1]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"D LOG_DEBUG logger H DBG 1337 (1x) [ ] [var: 1337, occurred: 1]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"I LOG_INFO logger H INF 1337 (1x) [ ] [var: 1337, occurred: 1]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"N LOG_NOTICE logger H NTC 1337 (1x) [ ] [var: 1337, occurred: 1]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"W LOG_WARNING logger H WRN 1337 (1x) [ ] [var: 1337, occurred: 1]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"E LOG_ERROR logger H ERR 1337 (1x) [ ] [var: 1337, occurred: 1]"})); + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"C LOG_CRITICAL logger H CRT 1337 (1x) [ ] [var: 1337, occurred: 1]"})); + + REQUIRE(quill::testing::file_contains( + file_contents, std::string{"T3 LOG_TRACE_L3 logger HA L3 1337 [ ] [var: 1337]"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"T2 LOG_TRACE_L2 logger H L2 1337 [ ] [var: 1337]"})); + file_contents, std::string{"T2 LOG_TRACE_L2 logger HA L2 1337 [ ] [var: 1337]"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"T1 LOG_TRACE_L1 logger H L1 1337 [ ] [var: 1337]"})); + file_contents, std::string{"T1 LOG_TRACE_L1 logger HA L1 1337 [ ] [var: 1337]"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"D LOG_DEBUG logger H DBG 1337 [ ] [var: 1337]"})); + file_contents, std::string{"D LOG_DEBUG logger HA DBG 1337 [ ] [var: 1337]"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"I LOG_INFO logger H INF 1337 [ ] [var: 1337]"})); + file_contents, std::string{"I LOG_INFO logger HA INF 1337 [ ] [var: 1337]"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"N LOG_NOTICE logger H NTC 1337 [ ] [var: 1337]"})); + file_contents, std::string{"N LOG_NOTICE logger HA NTC 1337 [ ] [var: 1337]"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"W LOG_WARNING logger H WRN 1337 [ ] [var: 1337]"})); + file_contents, std::string{"W LOG_WARNING logger HA WRN 1337 [ ] [var: 1337]"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"E LOG_ERROR logger H ERR 1337 [ ] [var: 1337]"})); + file_contents, std::string{"E LOG_ERROR logger HA ERR 1337 [ ] [var: 1337]"})); REQUIRE(quill::testing::file_contains( - file_contents, std::string{"C LOG_CRITICAL logger H CRT 1337 [ ] [var: 1337]"})); + file_contents, std::string{"C LOG_CRITICAL logger HA CRT 1337 [ ] [var: 1337]"})); REQUIRE(quill::testing::file_contains( file_contents, std::string{"T3 LOG_TRACE_L3 logger K L3 1337 [ #tag ] [var: 1337]"}));