From 09ff9252575e076375d1e414126466459c21e6d3 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 17 Nov 2010 19:12:08 +0000 Subject: Aggregate Timer warnings. The Timer code logs a warning if a timer callback is started late or overruns the start time for the next callback. In cases where there are a lot of these warnings, the time taken to do the logging itself severly worsens the situation. This commit aggregates timer warnings and give a statistical report every 5 seconds at most. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1036169 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/include/qpid/log/Statement.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cpp/include') diff --git a/cpp/include/qpid/log/Statement.h b/cpp/include/qpid/log/Statement.h index 8f73175630..7b3ab60b81 100644 --- a/cpp/include/qpid/log/Statement.h +++ b/cpp/include/qpid/log/Statement.h @@ -95,6 +95,24 @@ struct Statement { stmt_.log(::qpid::Msg() << MESSAGE); \ } while(0) +/** + * FLAG must be a boolean variable. Assigns FLAG to true iff logging + * is enabled for LEVEL in the calling context. Use when extra + * support code is needed to generate log messages, to ensure that it + * is only run if the logging level is enabled. + * e.g. + * bool logWarning; + * QPID_LOG_TEST(LEVEL, logWarning); + * if (logWarning) { do stuff needed for warning log messages } + */ +#define QPID_LOG_TEST(LEVEL, FLAG) \ + do { \ + using ::qpid::log::Statement; \ + static Statement stmt_= QPID_LOG_STATEMENT_INIT(LEVEL); \ + static Statement::Initializer init_(stmt_); \ + FLAG = stmt_.enabled; \ + } while(0) + /** * Macro for log statements. Example of use: * @code -- cgit v1.2.1