summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/test_tools.h
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src/tests/test_tools.h')
-rw-r--r--qpid/cpp/src/tests/test_tools.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/qpid/cpp/src/tests/test_tools.h b/qpid/cpp/src/tests/test_tools.h
index 32127b0442..37a6594f8a 100644
--- a/qpid/cpp/src/tests/test_tools.h
+++ b/qpid/cpp/src/tests/test_tools.h
@@ -18,9 +18,9 @@
* limitations under the License.
*
*/
+#include "qpid/log/Logger.h"
#include <limits.h> // Include before boost/test headers.
-
#include <boost/test/test_tools.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/regex.hpp>
@@ -78,5 +78,17 @@ inline bool regexPredicate(const std::string& re, const std::string& text) {
/** Check if types of two objects (as given by typeinfo::name()) match. */
#define BOOST_CHECK_TYPEID_EQUAL(a,b) BOOST_CHECK_EQUAL(typeid(a).name(),typeid(b).name())
+/**
+ * Supress all logging in a scope, restore to previous configuration in destructor.
+ */
+struct ScopedSuppressLogging {
+ typedef qpid::log::Logger Logger;
+ ScopedSuppressLogging(Logger& l=Logger::instance()) : logger(l), opts(l.getOptions()) { l.clear(); }
+ ~ScopedSuppressLogging() { logger.configure(opts); }
+ Logger& logger;
+ qpid::log::Options opts;
+};
+
+
#endif /*!TEST_TOOLS_H*/