diff options
| author | Alan Conway <aconway@apache.org> | 2008-05-22 15:02:11 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-05-22 15:02:11 +0000 |
| commit | 3ee4d6aeac14d4dcf7df7cd531b7a2778714bdcd (patch) | |
| tree | a0fa264f697336c46b0f4bf9c5dd437f64964010 /cpp/src/qpid/log | |
| parent | c5376d890443906f47980e4d76f5e7e0589b7f9e (diff) | |
| download | qpid-python-3ee4d6aeac14d4dcf7df7cd531b7a2778714bdcd.tar.gz | |
Improved logging for session state.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@659127 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/log')
| -rw-r--r-- | cpp/src/qpid/log/Statement.h | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/cpp/src/qpid/log/Statement.h b/cpp/src/qpid/log/Statement.h index 18162971b0..f765df1cf4 100644 --- a/cpp/src/qpid/log/Statement.h +++ b/cpp/src/qpid/log/Statement.h @@ -79,6 +79,26 @@ struct Statement { { 0, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (::qpid::log::level) } /** + * Like QPID_LOG but computes an additional boolean test expression + * to determine if the message should be logged. Evaluation of both + * the test and message expressions occurs only if the requested log level + * is enabled. + *@param LEVEL severity Level for message, should be one of: + * debug, info, notice, warning, error, critical. NB no qpid::log:: prefix. + *@param TEST message is logged only if expression TEST evaluates to true. + *@param MESSAGE any object with an @eostream operator<<, or a sequence + * like of ostreamable objects separated by @e<<. + */ +#define QPID_LOG_IF(LEVEL, TEST, MESSAGE) \ + do { \ + using ::qpid::log::Statement; \ + static Statement stmt_= QPID_LOG_STATEMENT_INIT(LEVEL); \ + static Statement::Initializer init_(stmt_); \ + if (stmt_.enabled && (TEST)) \ + stmt_.log(::qpid::Msg() << MESSAGE); \ + } while(0) + +/** * Macro for log statements. Example of use: * @code * QPID_LOG(debug, "There are " << foocount << " foos in the bar."); @@ -97,13 +117,7 @@ struct Statement { *@param MESSAGE any object with an @eostream operator<<, or a sequence * like of ostreamable objects separated by @e<<. */ -#define QPID_LOG(level, message) \ - do { \ - static ::qpid::log::Statement stmt_= QPID_LOG_STATEMENT_INIT(level); \ - static ::qpid::log::Statement::Initializer init_(stmt_); \ - if (stmt_.enabled) \ - stmt_.log(::qpid::Msg() << message); \ - } while(0) +#define QPID_LOG(LEVEL, MESSAGE) QPID_LOG_IF(LEVEL, true, MESSAGE); }} // namespace qpid::log |
