1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Predefined log format selection</title> 5<link rel="stylesheet" href="../../../boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../index.html" title="Boost.Test"> 8<link rel="up" href="../logging_api.html" title="Logging API"> 9<link rel="prev" href="log_ct_log_level.html" title="Log level configuration"> 10<link rel="next" href="custom_log_formatter.html" title="Custom log format support"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="log_ct_log_level.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../logging_api.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="custom_log_formatter.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="boost_test.test_output.logging_api.log_ct_log_format"></a><a class="link" href="log_ct_log_format.html" title="Predefined log format selection">Predefined 28 log format selection</a> 29</h4></div></div></div> 30<p> 31 The select at compile time the log format from the list of the formats 32 supplied by the <span class="emphasis"><em>Unit Test Framework</em></span> 33 </p> 34<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">unit_test_log</span><span class="special">.</span><span class="identifier">set_format</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">output_format</span> <span class="special">);</span> 35</pre> 36<p> 37 or for adding a format: 38 </p> 39<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">unit_test_log</span><span class="special">.</span><span class="identifier">add_format</span><span class="special">(</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">output_format</span> <span class="special">);</span> 40</pre> 41<div class="caution"><table border="0" summary="Caution"> 42<tr> 43<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../../../../../../doc/src/images/caution.png"></td> 44<th align="left">Caution</th> 45</tr> 46<tr><td align="left" valign="top"><p> 47 <code class="computeroutput"><a class="link" href="../../../boost/unit_test/unit_test_log_t.html#idm45267286522816-bb">boost::unit_test::unit_test_log_t::set_format</a></code> 48 above disables all formatters but the one provided as argument. 49 </p></td></tr> 50</table></div> 51<div class="tip"><table border="0" summary="Tip"> 52<tr> 53<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../../doc/src/images/tip.png"></td> 54<th align="left">Tip</th> 55</tr> 56<tr><td align="left" valign="top"><p> 57 See <code class="computeroutput"><a class="link" href="../../../boost/unit_test/unit_test_log_t.html#idm45267286522816-bb">boost::unit_test::unit_test_log_t::set_format</a></code> 58 and <code class="computeroutput"><a class="link" href="../../../header/boost/test/detail/global_typedef_hpp.html#boost.unit_test.output_format">boost::unit_test::output_format</a></code> 59 for more details 60 </p></td></tr> 61</table></div> 62<p> 63 In regular circumstances you shouldn't use this interface. Prefer to use 64 runtime parameters <a class="link" href="../../utf_reference/rt_param_reference/log_format.html" title="log_format"><code class="computeroutput"><span class="special">--</span><span class="identifier">log_format</span></code></a> 65 or <a class="link" href="../../utf_reference/rt_param_reference/logger.html" title="logger"><code class="computeroutput"><span class="special">--</span><span class="identifier">logger</span></code></a> 66 for predefined log format selection. 67 </p> 68<h6> 69<a name="boost_test.test_output.logging_api.log_ct_log_format.h0"></a> 70 <span class="phrase"><a name="boost_test.test_output.logging_api.log_ct_log_format.example_descr"></a></span><a class="link" href="log_ct_log_format.html#boost_test.test_output.logging_api.log_ct_log_format.example_descr">Example: 71 Compile-time log format selection</a> 72 </h6> 73<div class="informaltable"><table class="table"> 74<colgroup><col></colgroup> 75<thead><tr><th> 76 <p> 77 Code 78 </p> 79 </th></tr></thead> 80<tbody><tr><td> 81<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_MODULE</span> <span class="identifier">example</span> 82<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">included</span><span class="special">/</span><span class="identifier">unit_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 83<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">;</span> 84 85<span class="keyword">struct</span> <span class="identifier">MyConfig</span> <span class="special">{</span> 86 <span class="identifier">MyConfig</span><span class="special">()</span> <span class="special">{</span> 87 <span class="identifier">unit_test_log</span><span class="special">.</span><span class="identifier">set_format</span><span class="special">(</span> <span class="identifier">OF_XML</span> <span class="special">);</span> 88 <span class="special">}</span> 89 <span class="special">~</span><span class="identifier">MyConfig</span><span class="special">()</span> <span class="special">{}</span> 90<span class="special">};</span> 91 92<span class="identifier">BOOST_TEST_GLOBAL_CONFIGURATION</span><span class="special">(</span> <span class="identifier">MyConfig</span> <span class="special">);</span> 93 94<span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span> <span class="identifier">test_case0</span> <span class="special">)</span> <span class="special">{</span> 95 <span class="identifier">BOOST_TEST</span><span class="special">(</span> <span class="keyword">false</span> <span class="special">);</span> 96<span class="special">}</span> 97</pre> 98 </td></tr></tbody> 99</table></div> 100<div class="informaltable"><table class="table"> 101<colgroup><col></colgroup> 102<thead><tr><th> 103 <p> 104 Output 105 </p> 106 </th></tr></thead> 107<tbody><tr><td> 108<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">></span> <span class="identifier">example</span> <span class="special">--</span><span class="identifier">report_level</span><span class="special">=</span><span class="identifier">no</span> 109<span class="special"><</span><span class="identifier">TestLog</span><span class="special">><</span><span class="identifier">Error</span> <span class="identifier">file</span><span class="special">=</span><span class="string">"test.cpp"</span> <span class="identifier">line</span><span class="special">=</span><span class="string">"23"</span><span class="special">></span><span class="identifier">check</span> <span class="keyword">false</span> <span class="identifier">failed</span><span class="special"></</span><span class="identifier">Error</span><span class="special">></</span><span class="identifier">TestLog</span><span class="special">></span> 110</pre> 111 </td></tr></tbody> 112</table></div> 113</div> 114<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 115<td align="left"></td> 116<td align="right"><div class="copyright-footer">Copyright © 2001-2020 Boost.Test contributors<p> 117 Distributed under the Boost Software License, Version 1.0. (See accompanying 118 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 119 </p> 120</div></td> 121</tr></table> 122<hr> 123<div class="spirit-nav"> 124<a accesskey="p" href="log_ct_log_level.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../logging_api.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="custom_log_formatter.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 125</div> 126</body> 127</html> 128