Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

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

Code

#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 );
}

Output

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

*** No errors detected

PrevUpHomeNext