Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.

Log level configuration

If you need to enforce specific log level from within your test module use the following interface:

boost::unit_test::unit_test_log.set_threshold_level( boost::unit_test::log_level );

In regular circumstances you shouldn't use this interface, since you not only override default log level, but also the one supplied at test execution time. Prefer to use runtime parameter log_level for log level selection.

Example: Compile-time log level configuration


#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test_parameters.hpp>
using namespace boost::unit_test;

BOOST_AUTO_TEST_CASE( test_case0 )
  if( runtime_config::get<log_level>( runtime_config::LOG_LEVEL ) < log_warnings )
    unit_test_log.set_threshold_level( log_warnings );

  BOOST_WARN( sizeof(int) > 4 );


> example
Running 1 test case...
test.cpp(13): warning in "test_case0": condition sizeof(int) > 4 is not satisfied

*** No errors detected