unit_test_log.ipp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. // (C) Copyright Gennadiy Rozental 2001.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. // File : $RCSfile$
  8. //
  9. // Version : $Revision$
  10. //
  11. // Description : implemets Unit Test Log
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_UNIT_TEST_LOG_IPP_012205GER
  14. #define BOOST_TEST_UNIT_TEST_LOG_IPP_012205GER
  15. // Boost.Test
  16. #include <boost/test/unit_test_log.hpp>
  17. #include <boost/test/unit_test_log_formatter.hpp>
  18. #include <boost/test/execution_monitor.hpp>
  19. #include <boost/test/framework.hpp>
  20. #include <boost/test/unit_test_parameters.hpp>
  21. #include <boost/test/utils/basic_cstring/compare.hpp>
  22. #include <boost/test/utils/foreach.hpp>
  23. #include <boost/test/output/compiler_log_formatter.hpp>
  24. #include <boost/test/output/xml_log_formatter.hpp>
  25. #include <boost/test/output/junit_log_formatter.hpp>
  26. // Boost
  27. #include <boost/shared_ptr.hpp>
  28. #include <boost/io/ios_state.hpp>
  29. typedef ::boost::io::ios_base_all_saver io_saver_type;
  30. #include <boost/test/detail/suppress_warnings.hpp>
  31. //____________________________________________________________________________//
  32. namespace boost {
  33. namespace unit_test {
  34. // ************************************************************************** //
  35. // ************** entry_value_collector ************** //
  36. // ************************************************************************** //
  37. namespace ut_detail {
  38. entry_value_collector const&
  39. entry_value_collector::operator<<( lazy_ostream const& v ) const
  40. {
  41. unit_test_log << v;
  42. return *this;
  43. }
  44. //____________________________________________________________________________//
  45. entry_value_collector const&
  46. entry_value_collector::operator<<( const_string v ) const
  47. {
  48. unit_test_log << v;
  49. return *this;
  50. }
  51. //____________________________________________________________________________//
  52. entry_value_collector::~entry_value_collector()
  53. {
  54. if( m_last )
  55. unit_test_log << log::end();
  56. }
  57. //____________________________________________________________________________//
  58. } // namespace ut_detail
  59. // ************************************************************************** //
  60. // ************** unit_test_log ************** //
  61. // ************************************************************************** //
  62. namespace {
  63. // log data
  64. struct unit_test_log_data_helper_impl {
  65. typedef boost::shared_ptr<unit_test_log_formatter> formatter_ptr;
  66. typedef boost::shared_ptr<io_saver_type> saver_ptr;
  67. bool m_enabled;
  68. output_format m_format;
  69. std::ostream* m_stream;
  70. saver_ptr m_stream_state_saver;
  71. formatter_ptr m_log_formatter;
  72. bool m_entry_in_progress;
  73. unit_test_log_data_helper_impl(unit_test_log_formatter* p_log_formatter, output_format format, bool enabled = false)
  74. : m_enabled( enabled )
  75. , m_format( format )
  76. , m_stream( &std::cout )
  77. , m_stream_state_saver( new io_saver_type( std::cout ) )
  78. , m_log_formatter()
  79. , m_entry_in_progress( false )
  80. {
  81. m_log_formatter.reset(p_log_formatter);
  82. m_log_formatter->set_log_level(log_all_errors);
  83. }
  84. // helper functions
  85. std::ostream& stream()
  86. {
  87. return *m_stream;
  88. }
  89. log_level get_log_level() const
  90. {
  91. return m_log_formatter->get_log_level();
  92. }
  93. };
  94. struct unit_test_log_impl {
  95. // Constructor
  96. unit_test_log_impl()
  97. {
  98. m_log_formatter_data.push_back( unit_test_log_data_helper_impl(new output::compiler_log_formatter, OF_CLF, true) ); // only this one is active by default,
  99. m_log_formatter_data.push_back( unit_test_log_data_helper_impl(new output::xml_log_formatter, OF_XML, false) );
  100. m_log_formatter_data.push_back( unit_test_log_data_helper_impl(new output::junit_log_formatter, OF_JUNIT, false) );
  101. }
  102. typedef std::vector<unit_test_log_data_helper_impl> v_formatter_data_t;
  103. v_formatter_data_t m_log_formatter_data;
  104. // entry data
  105. log_entry_data m_entry_data;
  106. bool has_entry_in_progress() const {
  107. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl const&, current_logger_data, m_log_formatter_data ) {
  108. if( current_logger_data.m_entry_in_progress )
  109. return true;
  110. }
  111. return false;
  112. }
  113. // check point data
  114. log_checkpoint_data m_checkpoint_data;
  115. void set_checkpoint( const_string file, std::size_t line_num, const_string msg )
  116. {
  117. assign_op( m_checkpoint_data.m_message, msg, 0 );
  118. m_checkpoint_data.m_file_name = file;
  119. m_checkpoint_data.m_line_num = line_num;
  120. }
  121. };
  122. unit_test_log_impl& s_log_impl() { static unit_test_log_impl the_inst; return the_inst; }
  123. } // local namespace
  124. //____________________________________________________________________________//
  125. void
  126. unit_test_log_t::test_start( counter_t test_cases_amount )
  127. {
  128. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  129. if( !current_logger_data.m_enabled || current_logger_data.get_log_level() == log_nothing )
  130. continue;
  131. current_logger_data.m_log_formatter->log_start( current_logger_data.stream(), test_cases_amount );
  132. if( runtime_config::get<bool>( runtime_config::btrt_build_info ) )
  133. current_logger_data.m_log_formatter->log_build_info( current_logger_data.stream() );
  134. //current_logger_data.stream().flush();
  135. current_logger_data.m_entry_in_progress = false;
  136. }
  137. }
  138. //____________________________________________________________________________//
  139. void
  140. unit_test_log_t::test_finish()
  141. {
  142. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  143. if( !current_logger_data.m_enabled || current_logger_data.get_log_level() == log_nothing )
  144. continue;
  145. current_logger_data.m_log_formatter->log_finish( current_logger_data.stream() );
  146. current_logger_data.stream().flush();
  147. }
  148. }
  149. //____________________________________________________________________________//
  150. void
  151. unit_test_log_t::test_aborted()
  152. {
  153. BOOST_TEST_LOG_ENTRY( log_messages ) << "Test is aborted";
  154. }
  155. //____________________________________________________________________________//
  156. void
  157. unit_test_log_t::test_unit_start( test_unit const& tu )
  158. {
  159. if( s_log_impl().has_entry_in_progress() )
  160. *this << log::end();
  161. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  162. if( !current_logger_data.m_enabled || current_logger_data.get_log_level() > log_test_units )
  163. continue;
  164. current_logger_data.m_log_formatter->test_unit_start( current_logger_data.stream(), tu );
  165. }
  166. }
  167. //____________________________________________________________________________//
  168. void
  169. unit_test_log_t::test_unit_finish( test_unit const& tu, unsigned long elapsed )
  170. {
  171. s_log_impl().m_checkpoint_data.clear();
  172. if( s_log_impl().has_entry_in_progress() )
  173. *this << log::end();
  174. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  175. if( !current_logger_data.m_enabled || current_logger_data.get_log_level() > log_test_units )
  176. continue;
  177. current_logger_data.m_log_formatter->test_unit_finish( current_logger_data.stream(), tu, elapsed );
  178. }
  179. }
  180. //____________________________________________________________________________//
  181. void
  182. unit_test_log_t::test_unit_skipped( test_unit const& tu, const_string reason )
  183. {
  184. if( s_log_impl().has_entry_in_progress() )
  185. *this << log::end();
  186. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  187. if( !current_logger_data.m_enabled || current_logger_data.get_log_level() > log_test_units )
  188. continue;
  189. current_logger_data.m_log_formatter->test_unit_skipped( current_logger_data.stream(), tu, reason );
  190. }
  191. }
  192. void
  193. unit_test_log_t::test_unit_aborted( test_unit const& tu )
  194. {
  195. if( s_log_impl().has_entry_in_progress() )
  196. *this << log::end();
  197. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  198. if( !current_logger_data.m_enabled || current_logger_data.get_log_level() > log_test_units )
  199. continue;
  200. current_logger_data.m_log_formatter->test_unit_aborted(current_logger_data.stream(), tu );
  201. }
  202. }
  203. //____________________________________________________________________________//
  204. void
  205. unit_test_log_t::exception_caught( execution_exception const& ex )
  206. {
  207. log_level l =
  208. ex.code() <= execution_exception::cpp_exception_error ? log_cpp_exception_errors :
  209. (ex.code() <= execution_exception::timeout_error ? log_system_errors
  210. : log_fatal_errors );
  211. if( s_log_impl().has_entry_in_progress() )
  212. *this << log::end();
  213. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  214. if( current_logger_data.m_enabled && l >= current_logger_data.get_log_level() ) {
  215. current_logger_data.m_log_formatter->log_exception_start( current_logger_data.stream(), s_log_impl().m_checkpoint_data, ex );
  216. log_entry_context( l );
  217. current_logger_data.m_log_formatter->log_exception_finish( current_logger_data.stream() );
  218. }
  219. }
  220. clear_entry_context();
  221. }
  222. //____________________________________________________________________________//
  223. void
  224. unit_test_log_t::set_checkpoint( const_string file, std::size_t line_num, const_string msg )
  225. {
  226. s_log_impl().set_checkpoint( file, line_num, msg );
  227. }
  228. //____________________________________________________________________________//
  229. char
  230. set_unix_slash( char in )
  231. {
  232. return in == '\\' ? '/' : in;
  233. }
  234. unit_test_log_t&
  235. unit_test_log_t::operator<<( log::begin const& b )
  236. {
  237. if( s_log_impl().has_entry_in_progress() )
  238. *this << log::end();
  239. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  240. if( current_logger_data.m_enabled ) {
  241. current_logger_data.m_stream_state_saver->restore();
  242. }
  243. }
  244. s_log_impl().m_entry_data.clear();
  245. assign_op( s_log_impl().m_entry_data.m_file_name, b.m_file_name, 0 );
  246. // normalize file name
  247. std::transform( s_log_impl().m_entry_data.m_file_name.begin(), s_log_impl().m_entry_data.m_file_name.end(),
  248. s_log_impl().m_entry_data.m_file_name.begin(),
  249. &set_unix_slash );
  250. s_log_impl().m_entry_data.m_line_num = b.m_line_num;
  251. return *this;
  252. }
  253. //____________________________________________________________________________//
  254. unit_test_log_t&
  255. unit_test_log_t::operator<<( log::end const& )
  256. {
  257. if( s_log_impl().has_entry_in_progress() ) {
  258. log_entry_context( s_log_impl().m_entry_data.m_level );
  259. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  260. if( current_logger_data.m_enabled && current_logger_data.m_entry_in_progress ) {
  261. current_logger_data.m_log_formatter->log_entry_finish( current_logger_data.stream() );
  262. }
  263. current_logger_data.m_entry_in_progress = false;
  264. }
  265. }
  266. clear_entry_context();
  267. return *this;
  268. }
  269. //____________________________________________________________________________//
  270. unit_test_log_t&
  271. unit_test_log_t::operator<<( log_level l )
  272. {
  273. s_log_impl().m_entry_data.m_level = l;
  274. return *this;
  275. }
  276. //____________________________________________________________________________//
  277. ut_detail::entry_value_collector
  278. unit_test_log_t::operator()( log_level l )
  279. {
  280. *this << l;
  281. return ut_detail::entry_value_collector();
  282. }
  283. //____________________________________________________________________________//
  284. bool
  285. unit_test_log_t::log_entry_start(output_format log_format)
  286. {
  287. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  288. if( current_logger_data.m_format != log_format )
  289. continue;
  290. if( current_logger_data.m_entry_in_progress )
  291. return true;
  292. if( !current_logger_data.m_enabled )
  293. return false;
  294. switch( s_log_impl().m_entry_data.m_level ) {
  295. case log_successful_tests:
  296. current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data,
  297. unit_test_log_formatter::BOOST_UTL_ET_INFO );
  298. break;
  299. case log_messages:
  300. current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data,
  301. unit_test_log_formatter::BOOST_UTL_ET_MESSAGE );
  302. break;
  303. case log_warnings:
  304. current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data,
  305. unit_test_log_formatter::BOOST_UTL_ET_WARNING );
  306. break;
  307. case log_all_errors:
  308. case log_cpp_exception_errors:
  309. case log_system_errors:
  310. current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data,
  311. unit_test_log_formatter::BOOST_UTL_ET_ERROR );
  312. break;
  313. case log_fatal_errors:
  314. current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data,
  315. unit_test_log_formatter::BOOST_UTL_ET_FATAL_ERROR );
  316. break;
  317. case log_nothing:
  318. case log_test_units:
  319. case invalid_log_level:
  320. return false;
  321. }
  322. current_logger_data.m_entry_in_progress = true;
  323. return true;
  324. }
  325. return false;
  326. }
  327. //____________________________________________________________________________//
  328. unit_test_log_t&
  329. unit_test_log_t::operator<<( const_string value )
  330. {
  331. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  332. if( current_logger_data.m_enabled && s_log_impl().m_entry_data.m_level >= current_logger_data.get_log_level() && !value.empty() && log_entry_start(current_logger_data.m_format) )
  333. current_logger_data.m_log_formatter->log_entry_value( current_logger_data.stream(), value );
  334. }
  335. return *this;
  336. }
  337. //____________________________________________________________________________//
  338. unit_test_log_t&
  339. unit_test_log_t::operator<<( lazy_ostream const& value )
  340. {
  341. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  342. if( current_logger_data.m_enabled && s_log_impl().m_entry_data.m_level >= current_logger_data.get_log_level() && !value.empty() ) {
  343. if( log_entry_start(current_logger_data.m_format) ) {
  344. current_logger_data.m_log_formatter->log_entry_value( current_logger_data.stream(), value );
  345. }
  346. }
  347. }
  348. return *this;
  349. }
  350. //____________________________________________________________________________//
  351. void
  352. unit_test_log_t::log_entry_context( log_level l )
  353. {
  354. framework::context_generator const& context = framework::get_context();
  355. if( context.is_empty() )
  356. return;
  357. const_string frame;
  358. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  359. if( current_logger_data.m_enabled ) {
  360. current_logger_data.m_log_formatter->entry_context_start( current_logger_data.stream(), l );
  361. }
  362. }
  363. while( !(frame=context.next()).is_empty() )
  364. {
  365. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  366. if( current_logger_data.m_enabled ) {
  367. current_logger_data.m_log_formatter->log_entry_context( current_logger_data.stream(), l, frame );
  368. }
  369. }
  370. }
  371. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  372. if( current_logger_data.m_enabled ) {
  373. current_logger_data.m_log_formatter->entry_context_finish( current_logger_data.stream(), l );
  374. }
  375. }
  376. }
  377. //____________________________________________________________________________//
  378. void
  379. unit_test_log_t::clear_entry_context()
  380. {
  381. framework::clear_context();
  382. }
  383. //____________________________________________________________________________//
  384. void
  385. unit_test_log_t::set_stream( std::ostream& str )
  386. {
  387. if( s_log_impl().has_entry_in_progress() )
  388. return;
  389. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  390. current_logger_data.m_stream = &str;
  391. current_logger_data.m_stream_state_saver.reset( new io_saver_type( str ) );
  392. }
  393. }
  394. //____________________________________________________________________________//
  395. void
  396. unit_test_log_t::set_stream( output_format log_format, std::ostream& str )
  397. {
  398. if( s_log_impl().has_entry_in_progress() )
  399. return;
  400. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  401. if( current_logger_data.m_format == log_format) {
  402. current_logger_data.m_stream = &str;
  403. current_logger_data.m_stream_state_saver.reset( new io_saver_type( str ) );
  404. break;
  405. }
  406. }
  407. }
  408. std::ostream*
  409. unit_test_log_t::get_stream( output_format log_format ) const
  410. {
  411. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  412. if( current_logger_data.m_format == log_format) {
  413. return current_logger_data.m_stream;
  414. }
  415. }
  416. return 0;
  417. }
  418. //____________________________________________________________________________//
  419. void
  420. unit_test_log_t::set_threshold_level( log_level lev )
  421. {
  422. if( s_log_impl().has_entry_in_progress() || lev == invalid_log_level )
  423. return;
  424. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  425. current_logger_data.m_log_formatter->set_log_level( lev );
  426. }
  427. }
  428. //____________________________________________________________________________//
  429. void
  430. unit_test_log_t::set_threshold_level( output_format log_format, log_level lev )
  431. {
  432. if( s_log_impl().has_entry_in_progress() || lev == invalid_log_level )
  433. return;
  434. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  435. if( current_logger_data.m_format == log_format) {
  436. current_logger_data.m_log_formatter->set_log_level( lev );
  437. break;
  438. }
  439. }
  440. }
  441. //____________________________________________________________________________//
  442. void
  443. unit_test_log_t::set_format( output_format log_format )
  444. {
  445. if( s_log_impl().has_entry_in_progress() )
  446. return;
  447. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  448. current_logger_data.m_enabled = current_logger_data.m_format == log_format;
  449. }
  450. }
  451. //____________________________________________________________________________//
  452. void
  453. unit_test_log_t::add_format( output_format log_format )
  454. {
  455. if( s_log_impl().has_entry_in_progress() )
  456. return;
  457. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  458. if( current_logger_data.m_format == log_format) {
  459. current_logger_data.m_enabled = true;
  460. break;
  461. }
  462. }
  463. }
  464. //____________________________________________________________________________//
  465. unit_test_log_formatter*
  466. unit_test_log_t::get_formatter( output_format log_format ) {
  467. BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) {
  468. if( current_logger_data.m_format == log_format) {
  469. return current_logger_data.m_log_formatter.get();
  470. }
  471. }
  472. return 0;
  473. }
  474. void
  475. unit_test_log_t::add_formatter( unit_test_log_formatter* the_formatter )
  476. {
  477. // remove only user defined logger
  478. for(unit_test_log_impl::v_formatter_data_t::iterator it(s_log_impl().m_log_formatter_data.begin()),
  479. ite(s_log_impl().m_log_formatter_data.end());
  480. it != ite;
  481. ++it)
  482. {
  483. if( it->m_format == OF_CUSTOM_LOGGER) {
  484. s_log_impl().m_log_formatter_data.erase(it);
  485. break;
  486. }
  487. }
  488. if( the_formatter ) {
  489. s_log_impl().m_log_formatter_data.push_back( unit_test_log_data_helper_impl(the_formatter, OF_CUSTOM_LOGGER, true) );
  490. }
  491. }
  492. void
  493. unit_test_log_t::set_formatter( unit_test_log_formatter* the_formatter )
  494. {
  495. // remove only user defined logger
  496. log_level current_level = invalid_log_level;
  497. std::ostream *current_stream = 0;
  498. output_format previous_format = OF_INVALID;
  499. for(unit_test_log_impl::v_formatter_data_t::iterator it(s_log_impl().m_log_formatter_data.begin()),
  500. ite(s_log_impl().m_log_formatter_data.end());
  501. it != ite;
  502. ++it)
  503. {
  504. if( it->m_enabled ) {
  505. if( current_level == invalid_log_level || it->m_format < previous_format || it->m_format == OF_CUSTOM_LOGGER) {
  506. current_level = it->get_log_level();
  507. current_stream = &(it->stream());
  508. previous_format = it->m_format;
  509. }
  510. }
  511. }
  512. if( the_formatter ) {
  513. add_formatter(the_formatter);
  514. set_format(OF_CUSTOM_LOGGER);
  515. set_threshold_level(OF_CUSTOM_LOGGER, current_level);
  516. set_stream(OF_CUSTOM_LOGGER, *current_stream);
  517. }
  518. }
  519. //____________________________________________________________________________//
  520. // ************************************************************************** //
  521. // ************** unit_test_log_formatter ************** //
  522. // ************************************************************************** //
  523. void
  524. unit_test_log_formatter::log_entry_value( std::ostream& ostr, lazy_ostream const& value )
  525. {
  526. log_entry_value( ostr, (wrap_stringstream().ref() << value).str() );
  527. }
  528. void
  529. unit_test_log_formatter::set_log_level(log_level new_log_level)
  530. {
  531. m_log_level = new_log_level;
  532. }
  533. log_level
  534. unit_test_log_formatter::get_log_level() const
  535. {
  536. return m_log_level;
  537. }
  538. //____________________________________________________________________________//
  539. } // namespace unit_test
  540. } // namespace boost
  541. #include <boost/test/detail/enable_warnings.hpp>
  542. #endif // BOOST_TEST_UNIT_TEST_LOG_IPP_012205GER