refactor(doc): better CSS and layout

This commit is contained in:
Johann Dreo 2023-01-20 12:39:15 +01:00
commit 735e7ffb4d
212 changed files with 45759 additions and 1252 deletions

View file

@ -9,10 +9,15 @@
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
@ -20,6 +25,7 @@
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="clutchlog_logo.svg"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">clutchlog
&#160;<span id="projectnumber">0.11.1</span>
@ -47,6 +53,22 @@ $(function() {
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('index.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
@ -73,20 +95,33 @@ $(function() {
<li class="level1"><a href="#autotoc_md3">Basic Usage</a><ul><li class="level2"><a href="#autotoc_md4">Calls</a></li>
<li class="level2"><a href="#autotoc_md5">Log level semantics</a></li>
<li class="level2"><a href="#autotoc_md6">Location filtering</a></li>
<li class="level2"><a href="#autotoc_md7">Output Configuration</a></li>
<li class="level2"><a href="#autotoc_md8">Output style</a></li>
<li class="level2"><a href="#autotoc_md7">Output Configuration</a><ul><li class="level3"><a href="#autotoc_md8">Log Format</a></li>
</ul>
</li>
<li class="level1"><a href="#autotoc_md9">Advanced Usage</a><ul><li class="level2"><a href="#autotoc_md10">More Output Configuration</a></li>
<li class="level2"><a href="#autotoc_md11">Disabled calls</a></li>
<li class="level2"><a href="#autotoc_md12">Low-level API</a></li>
<li class="level2"><a href="#autotoc_md13">(De)clutch any function call</a></li>
<li class="level2"><a href="#autotoc_md14">(De)clutch any code section</a></li>
<li class="level2"><a href="#autotoc_md9">Output style</a></li>
</ul>
</li>
<li class="level1"><a href="#autotoc_md15">Examples</a></li>
<li class="level1"><a href="#autotoc_md16">Limitations</a></li>
<li class="level1"><a href="#autotoc_md17">Build and tests</a></li>
<li class="level1"><a href="#autotoc_md10">Advanced Usage</a><ul><li class="level2"><a href="#autotoc_md11">More Output Configuration</a><ul><li class="level3"><a href="#autotoc_md12">Dump Format</a></li>
<li class="level3"><a href="#autotoc_md13">Marks</a></li>
<li class="level3"><a href="#autotoc_md14">Stack Depth</a></li>
</ul>
</li>
<li class="level2"><a href="#autotoc_md15">Disabled calls</a></li>
<li class="level2"><a href="#autotoc_md16">Low-level API</a></li>
<li class="level2"><a href="#autotoc_md17">(De)clutch any function call</a></li>
<li class="level2"><a href="#autotoc_md18">(De)clutch any code section</a></li>
</ul>
</li>
<li class="level1"><a href="#autotoc_md19">Examples</a></li>
<li class="level1"><a href="#autotoc_md20">Limitations</a><ul><ul><li class="level3"><a href="#autotoc_md21">System-dependent stack depth</a></li>
<li class="level3"><a href="#autotoc_md22">System-dependent horizontal fill</a></li>
<li class="level3"><a href="#autotoc_md23">Dependencies</a></li>
<li class="level3"><a href="#autotoc_md24">Variable names within the CLUTCHLOG macro</a></li>
<li class="level3"><a href="#autotoc_md25">Features</a></li>
</ul>
</ul>
</li>
<li class="level1"><a href="#autotoc_md26">Build and tests</a></li>
</ul>
</div>
<div class="textblock"><p><em><b>Clutchlog is a logging system that targets versatile debugging.</b></em> <em><b>It allows to (de)clutch messages for a given: log level, source code location or call stack depth.</b></em></p>
@ -114,7 +149,7 @@ Features</h1>
</ul>
<h1><a class="anchor" id="autotoc_md1"></a>
Example</h1>
<p>Adding a message is a simple as calling a macro (which is declutched in Debug build type, when <code>NDEBUG</code> is not defined): </p><div class="fragment"><div class="line"><a class="code" href="group__UseMacros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a>(info, <span class="stringliteral">&quot;matrix size: &quot;</span> &lt;&lt; m &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; n);</div>
<p>Adding a message is a simple as calling a macro (which is declutched in Debug build type, when <code>NDEBUG</code> is not defined): </p><div class="fragment"><div class="line"><a class="code" href="group___use_macros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a>(info, <span class="stringliteral">&quot;matrix size: &quot;</span> &lt;&lt; m &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; n);</div>
</div><!-- fragment --><p>To configure the display, you indicate the three types of locations, for example in your <code>main</code> function: </p><div class="fragment"><div class="line"><span class="keyword">auto</span>&amp; log = <a class="code" href="classclutchlog.html#acfaceb77da01503b432644a3efaee4fa">clutchlog::logger</a>();</div>
<div class="line">log.depth(2); <span class="comment">// Log functions called from &quot;main&quot; but not below.</span></div>
<div class="line">log.threshold(<span class="stringliteral">&quot;Info&quot;</span>); <span class="comment">// Log only &quot;info&quot;, &quot;warning&quot;, &quot;error&quot; or &quot;critical&quot; messages.</span></div>
@ -132,17 +167,17 @@ Basic Usage</h1>
<h2><a class="anchor" id="autotoc_md4"></a>
Calls</h2>
<p>The main entrypoint is the <code>CLUTCHLOG</code> macro, which takes the desired log level and message. The message can be anything that can be output in an <code>ostringstream</code>. </p><div class="fragment"><div class="line"><span class="comment">// Simple string:</span></div>
<div class="line"><a class="code" href="group__UseMacros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a>(info, <span class="stringliteral">&quot;hello world&quot;</span>);</div>
<div class="line"><a class="code" href="group___use_macros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a>(info, <span class="stringliteral">&quot;hello world&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Serialisable variable:</span></div>
<div class="line"><span class="keywordtype">double</span> value = 0;</div>
<div class="line"><a class="code" href="group__UseMacros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a>(error, value);</div>
<div class="line"><a class="code" href="group___use_macros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a>(error, value);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// passed using inline output stream operators:</span></div>
<div class="line"><a class="code" href="group__UseMacros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a>(debug, <span class="stringliteral">&quot;hello &quot;</span> &lt;&lt; value &lt;&lt; <span class="stringliteral">&quot; world&quot;</span>);</div>
<div class="line"><a class="code" href="group___use_macros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a>(debug, <span class="stringliteral">&quot;hello &quot;</span> &lt;&lt; value &lt;&lt; <span class="stringliteral">&quot; world&quot;</span>);</div>
</div><!-- fragment --><p>There is also a macro to dump the content of an iterable within a separate file: <code>CLUTCHDUMP</code>. This function takes care of incrementing a numeric suffix in the file name, if an existing file with this name exists. </p><div class="fragment"><div class="line">std::vector&lt;int&gt; v(10);</div>
<div class="line">std::generate(v.begin(), v.end(), std::rand);</div>
<div class="line"><a class="code" href="group__UseMacros.html#ga572e3aa19d8b39e3ed0b9e91961104c2">CLUTCHDUMP</a>(debug, vec, <span class="stringliteral">&quot;test_{n}.dat&quot;</span>);</div>
<div class="line"><a class="code" href="group___use_macros.html#ga572e3aa19d8b39e3ed0b9e91961104c2">CLUTCHDUMP</a>(debug, vec, <span class="stringliteral">&quot;test_{n}.dat&quot;</span>);</div>
<div class="line"><span class="comment">/* Will output in cat &quot;rand_0.dat&quot;</span></div>
<div class="line"><span class="comment">* # [t-dump] Info in main (at depth 5) @ /home/nojhan/code/clutchlog/tests/t-dump.cpp:22</span></div>
<div class="line"><span class="comment">* 1804289383</span></div>
@ -196,10 +231,11 @@ Output Configuration</h2>
<li><code>{depth_marks}</code>: as many chevrons <code>&gt;</code> as there is calls in the stack,</li>
<li><code>{hfill}</code>: Inserts a sequence of characters that will stretch to fill the space available in the current terminal, between the rightmost and leftmost part of the log message.</li>
</ul>
<h3>Log Format</h3>
<h3><a class="anchor" id="autotoc_md8"></a>
Log Format</h3>
<p>The default log format is <code>"[{name}] {level_letter}:{depth_marks} {msg} {hfill} {func} @ {file}:{line}\n"</code>, it can be overriden at compile time by defining the <code>CLUTCHLOG_DEFAULT_FORMAT</code> macro.</p>
<p>By default, and if <code>CLUTCHLOG_DEFAULT_FORMAT</code> is not defined, clutchlog will not put the location-related tags in the message formats (i.e. <code>{name}</code>, <code>{func}</code>, and <code>{line}</code>) when not in Debug builds.</p>
<h2><a class="anchor" id="autotoc_md8"></a>
<h2><a class="anchor" id="autotoc_md9"></a>
Output style</h2>
<p>Output lines can be colored differently depending on the log level. </p><div class="fragment"><div class="line"><span class="comment">// Print error messages in bold red:</span></div>
<div class="line">log.style(clutchlog::level::error, <span class="comment">// First, the log level.</span></div>
@ -248,22 +284,25 @@ Output style</h2>
</div><!-- fragment --><p>Note: messages at the "critical", "error" and "warning" log levels are colored by default. You may want to set their style to <code>none</code> if you want to stay in control of inserted colors in the format template.</p>
<p>The horizontal filling line (the <code>{hfill}</code> tag) can be configured separately with <code>clutchlog::hfill_style</code>, for example: </p><div class="fragment"><div class="line">log.hfill_style(clutchlog::fmt::fg::black);</div>
</div><!-- fragment --><p>Note: this will actually reset any styling after the hfill, disabling any style you would have set for the whole message using <code><a class="el" href="classclutchlog.html#a656c277e074b64728cca871f2b484d1c" title="Set the template string.">clutchlog::format</a></code> for the remaining of the message.</p>
<h1><a class="anchor" id="autotoc_md9"></a>
<h1><a class="anchor" id="autotoc_md10"></a>
Advanced Usage</h1>
<h2><a class="anchor" id="autotoc_md10"></a>
<h2><a class="anchor" id="autotoc_md11"></a>
More Output Configuration</h2>
<h3>Dump Format</h3>
<h3><a class="anchor" id="autotoc_md12"></a>
Dump Format</h3>
<p>The default format of the first line of comment added with the dump macro is <code>"# [{name}] {level} in {func} (at depth {depth}) @ {file}:{line}"</code>. It can be edited with the <code>format_comment</code> method. If it is set to an empty string, then no comment line is added. The default can be modified at compile time with <code>CLUTCHDUMP_DEFAULT_FORMAT</code>.</p>
<p>By default, the separator between items in the container is a new line. To change this behaviour, you can change <code>CLUTCHDUMP_DEFAULT_SEP</code> or call the low-level <code>dump</code> method.</p>
<p>By default, and if <code>CLUTCHDUMP_DEFAULT_FORMAT</code> is not defined, clutchlog will not put the location-related tags in the message formats (i.e. <code>{file}</code> and <code>{line}</code>) when not in Debug builds.</p>
<h3>Marks</h3>
<p>The mark used with the <code>{depth_marks}</code> tag can be configured with the <code>clutchlog::depth_mark</code> method, and its default with the <code>CLUTCHLOG_DEFAULT_DEPTH_MARK</code> macro: </p><div class="fragment"><div class="line">log.depth_mark(<a class="code" href="group__DefaultConfig.html#ga45c4c964fad4ad1641d5c9c28c4645b9">CLUTCHLOG_DEFAULT_DEPTH_MARK</a>); <span class="comment">// Defaults to &quot;&gt;&quot;.</span></div>
<h3><a class="anchor" id="autotoc_md13"></a>
Marks</h3>
<p>The mark used with the <code>{depth_marks}</code> tag can be configured with the <code>clutchlog::depth_mark</code> method, and its default with the <code>CLUTCHLOG_DEFAULT_DEPTH_MARK</code> macro: </p><div class="fragment"><div class="line">log.depth_mark(<a class="code" href="group___default_config.html#ga45c4c964fad4ad1641d5c9c28c4645b9">CLUTCHLOG_DEFAULT_DEPTH_MARK</a>); <span class="comment">// Defaults to &quot;&gt;&quot;.</span></div>
</div><!-- fragment --><p>The character used with the <code>{hfill}</code> tag can be configured wth the <code>clutchlog::hfill_mark</code> method, and its default with the <code>CLUTCHLOG_DEFAULT_HFILL_MARK</code> macro: </p><div class="fragment"><div class="line">log.hfill_mark(CLUTCHLOG_DEFAULT_HFILL_MARK); <span class="comment">// Defaults to &#39;.&#39;.</span></div>
</div><!-- fragment --><p>Clutchlog measures the width of the standard error channel. If it is redirected, it may be measured as very large. Thus, the <code>clutchlog::hfill_max</code> accessors allow to set a maximum width (in number of characters). </p><div class="fragment"><div class="line">log.hfill_max(CLUTCHLOG_DEFAULT_HFILL_MAX); <span class="comment">// Defaults to 300.</span></div>
</div><!-- fragment --><p>Note: clutchlog will select the minimum between <code>clutchlog::hfill_max</code> and the measured number of columns in the terminal, so that you may use <code>clutchlog::hfill_max</code> as a way to constraint the output width in any cases.</p>
<h3>Stack Depth</h3>
<p>By default, clutchlog removes 5 levels of the calls stack, so that your <code>main</code> entrypoint corresponds to a depth of zero. You can change this behaviour by defining the <code>CLUTCHLOG_STRIP_CALLS</code> macro, or calling <code>clutchlog::strip_calls</code>. </p><div class="fragment"><div class="line">log.strip_calls(<a class="code" href="group__DefaultConfig.html#ga98f30d814d4913a8a7c93a8793f49adf">CLUTCHLOG_STRIP_CALLS</a>); <span class="comment">// Defaults to 5.</span></div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md11"></a>
<h3><a class="anchor" id="autotoc_md14"></a>
Stack Depth</h3>
<p>By default, clutchlog removes 5 levels of the calls stack, so that your <code>main</code> entrypoint corresponds to a depth of zero. You can change this behaviour by defining the <code>CLUTCHLOG_STRIP_CALLS</code> macro, or calling <code>clutchlog::strip_calls</code>. </p><div class="fragment"><div class="line">log.strip_calls(<a class="code" href="group___default_config.html#ga98f30d814d4913a8a7c93a8793f49adf">CLUTCHLOG_STRIP_CALLS</a>); <span class="comment">// Defaults to 5.</span></div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md15"></a>
Disabled calls</h2>
<p>By default, clutchlog is always enabled if the <code>NDEBUG</code> preprocessor variable is not defined (this variable is set by CMake in build types that differs from <code>Debug</code>).</p>
<p>You can however force clutchlog to be enabled in any build type by setting the <code>WITH_CLUTCHLOG</code> preprocessor variable.</p>
@ -272,26 +311,26 @@ Disabled calls</h2>
<div class="line"><span class="preprocessor">#define CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG clutchlog::level::xdebug</span></div>
</div><!-- fragment --><p>Note that allowing a log level does not mean that it will actually output something. If the configured log level at runtime is lower than the log level of the message, it will still not be printed.</p>
<p>This behavior intend to remove as many conditional statements as possible when not debugging, without having to use preprocessor guards around calls to clutchlog, thus saving run time at no readability cost.</p>
<h2><a class="anchor" id="autotoc_md12"></a>
<h2><a class="anchor" id="autotoc_md16"></a>
Low-level API</h2>
<p>All configuration setters have a getters counterpart, with the same name but taking no parameter, for example: </p><div class="fragment"><div class="line">std::string mark = log.depth_mark();</div>
</div><!-- fragment --><p>To control more precisely the logging, one can use the low-level <code><a class="el" href="classclutchlog.html#a23dbb98f0d3c5cc21c232cde16cf317a" title="Print a log message IF the location matches the given one.">clutchlog::log</a></code> method: </p><div class="fragment"><div class="line">log.log(clutchlog::level::xdebug, <span class="stringliteral">&quot;hello world&quot;</span>, <span class="stringliteral">&quot;main.cpp&quot;</span>, <span class="stringliteral">&quot;main&quot;</span>, 122);</div>
</div><!-- fragment --><p>A helper macro can helps to fill in the location with the actual one, as seen by the compiler: </p><div class="fragment"><div class="line">log.log(clutchlog::level::xdebug, <span class="stringliteral">&quot;hello world&quot;</span>, <a class="code" href="group__UseMacros.html#gae8911119d726a43b77f5781cb5a72813">CLUTCHLOC</a>);</div>
</div><!-- fragment --><p>A similar <code>dump</code> method exists: </p><div class="fragment"><div class="line">log.dump(clutchlog::level::xdebug, cont.begin(), cont.end(), <a class="code" href="group__UseMacros.html#gae8911119d726a43b77f5781cb5a72813">CLUTCHLOC</a>, <span class="stringliteral">&quot;dumped_{n}.dat&quot;</span>, <span class="stringliteral">&quot;\n&quot;</span>);</div>
</div><!-- fragment --><p>A helper macro can helps to fill in the location with the actual one, as seen by the compiler: </p><div class="fragment"><div class="line">log.log(clutchlog::level::xdebug, <span class="stringliteral">&quot;hello world&quot;</span>, <a class="code" href="group___use_macros.html#gae8911119d726a43b77f5781cb5a72813">CLUTCHLOC</a>);</div>
</div><!-- fragment --><p>A similar <code>dump</code> method exists: </p><div class="fragment"><div class="line">log.dump(clutchlog::level::xdebug, cont.begin(), cont.end(), <a class="code" href="group___use_macros.html#gae8911119d726a43b77f5781cb5a72813">CLUTCHLOC</a>, <span class="stringliteral">&quot;dumped_{n}.dat&quot;</span>, <span class="stringliteral">&quot;\n&quot;</span>);</div>
<div class="line">log.dump(clutchlog::level::xdebug, cont.begin(), cont.end(), <span class="stringliteral">&quot;main.cpp&quot;</span>, <span class="stringliteral">&quot;main&quot;</span>, 122, <span class="stringliteral">&quot;dumped.dat&quot;</span>, <span class="stringliteral">&quot;\n\n&quot;</span>);</div>
</div><!-- fragment --><p>You can access the identifier of log levels with <code><a class="el" href="classclutchlog.html#acebed8c9df9204f22bf8488e62e1cedd" title="Return the log level tag corresponding to the given pre-configured name.">clutchlog::level_of</a></code>: </p><div class="fragment"><div class="line">log.threshold( log.level_of(<span class="stringliteral">&quot;XDebug&quot;</span>) ); <span class="comment">// You have to know the exact string.</span></div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md13"></a>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md17"></a>
(De)clutch any function call</h2>
<p>The <code>CLUTHFUNC</code> macro allows to wrap any function within the current logger.</p>
<p>For instance, this can be useful if you want to (de)clutch calls to <code>assert</code>s. To do that, just declare your own macro: </p><div class="fragment"><div class="line"><span class="preprocessor">#define ASSERT(...) { CLUTCHFUNC(error, assert, __VA_ARGS__) }</span></div>
</div><!-- fragment --><p>Thus, any call like <code>ASSERT(x &gt; 3);</code> will be declutchable with the same configuration than a call to <code>CLUTCHLOG</code>.</p>
<h2><a class="anchor" id="autotoc_md14"></a>
<h2><a class="anchor" id="autotoc_md18"></a>
(De)clutch any code section</h2>
<p>The <code>CLUTCHCODE</code> macro allows to wrap any code within the current logger.</p>
<p>For instance: </p><div class="fragment"><div class="line"><a class="code" href="group__UseMacros.html#gaaf2e85e1153e6c88b458dd49e3c37c73">CLUTCHCODE</a>(info,</div>
<p>For instance: </p><div class="fragment"><div class="line"><a class="code" href="group___use_macros.html#gaaf2e85e1153e6c88b458dd49e3c37c73">CLUTCHCODE</a>(info,</div>
<div class="line"> std::clog &lt;&lt; <span class="stringliteral">&quot;We are clutched!\n&quot;</span>;</div>
<div class="line">);</div>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md15"></a>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md19"></a>
Examples</h1>
<p>Here what you would do to setup clutchlog with the default configuration: </p><div class="fragment"><div class="line"><span class="keyword">auto</span>&amp; log = <a class="code" href="classclutchlog.html#acfaceb77da01503b432644a3efaee4fa">clutchlog::logger</a>();</div>
<div class="line">log.out(std::clog);</div>
@ -319,43 +358,48 @@ Examples</h1>
<div class="line">log.hfill_max(300);</div>
<div class="line">log.hfill_style(clutchlog::fmt::fg::none);</div>
</div><!-- fragment --><p>And here are all the functions you may call to log something: </p><div class="fragment"><div class="line"><span class="comment">// Basic message.</span></div>
<div class="line"><a class="code" href="group__UseMacros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a>(debug, <span class="stringliteral">&quot;x = &quot;</span> &lt;&lt; x);</div>
<div class="line"><a class="code" href="group___use_macros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a>(debug, <span class="stringliteral">&quot;x = &quot;</span> &lt;&lt; x);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Any code section.</span></div>
<div class="line"><a class="code" href="group__UseMacros.html#gaaf2e85e1153e6c88b458dd49e3c37c73">CLUTCHCODE</a>(xdebug,</div>
<div class="line"><a class="code" href="group___use_macros.html#gaaf2e85e1153e6c88b458dd49e3c37c73">CLUTCHCODE</a>(xdebug,</div>
<div class="line"> <span class="keywordflow">if</span>(x &lt; 0) std::cerr &lt;&lt; <span class="stringliteral">&quot;WTF?&quot;</span> &lt;&lt; std::endl;</div>
<div class="line">);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Container to a file.</span></div>
<div class="line"><a class="code" href="group__UseMacros.html#ga572e3aa19d8b39e3ed0b9e91961104c2">CLUTCHDUMP</a>(note, my_vector, <span class="stringliteral">&quot;my_vector.dat&quot;</span>);</div>
<div class="line"><a class="code" href="group___use_macros.html#ga572e3aa19d8b39e3ed0b9e91961104c2">CLUTCHDUMP</a>(note, my_vector, <span class="stringliteral">&quot;my_vector.dat&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Container to a numbered file.</span></div>
<div class="line"><a class="code" href="group__UseMacros.html#ga572e3aa19d8b39e3ed0b9e91961104c2">CLUTCHDUMP</a>(note, my_list, <span class="stringliteral">&quot;my_list_{n}.dat&quot;</span>);</div>
<div class="line"><a class="code" href="group___use_macros.html#ga572e3aa19d8b39e3ed0b9e91961104c2">CLUTCHDUMP</a>(note, my_list, <span class="stringliteral">&quot;my_list_{n}.dat&quot;</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Function call.</span></div>
<div class="line"><a class="code" href="group__UseMacros.html#ga9f77cee4f853e582262930c9c17f90ae">CLUTCHFUNC</a>(warning, my_check, x, y); <span class="comment">// Calls: my_check(x,y);</span></div>
<div class="line"><a class="code" href="group___use_macros.html#ga9f77cee4f853e582262930c9c17f90ae">CLUTCHFUNC</a>(warning, my_check, x, y); <span class="comment">// Calls: my_check(x,y);</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// Declutchable asserts.</span></div>
<div class="line"><span class="preprocessor">#define ASSERT(...) { CLUTCHFUNC(critical, assert, __VA_ARGS__) }</span></div>
<div class="line"><span class="preprocessor">ASSERT(x&gt;0);</span></div>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md16"></a>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md20"></a>
Limitations</h1>
<h3>System-dependent stack depth</h3>
<h3><a class="anchor" id="autotoc_md21"></a>
System-dependent stack depth</h3>
<p>Because access to the call stack depth and program name are system-dependent, the features relying on the depth of the call stack and the display of the program name are only available for operating systems having the following headers: <code>execinfo.h</code>, <code>stdlib.h</code> and <code>libgen.h</code> (so far, tested with Linux).</p>
<p>Clutchlog sets the <code>CLUTCHLOG_HAVE_UNIX_SYSINFO</code> to 1 if the headers are available, and to 0 if they are not. You can make portable code using something like: </p><div class="fragment"><div class="line"><span class="preprocessor">#if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1</span></div>
<div class="line"> log.depth( x );</div>
<div class="line"><span class="preprocessor">#endif </span></div>
</div><!-- fragment --><h3>System-dependent horizontal fill</h3>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md22"></a>
System-dependent horizontal fill</h3>
<p>Because access to the current terminal width is system-dependent, the <code>{hfill}</code> format tag feature is only available for operating systems having the following headers: <code>sys/ioctl.h</code>, <code>stdio.h</code> and <code>unistd.h</code> (so far, tested with Linux).</p>
<p>Clutchlog sets the <code>CLUTCHLOG_HAVE_UNIX_SYSIOCTL</code> to 1 if the headers are available, and to 0 if they are not. You can make portable code using something like: </p><div class="fragment"><div class="line"><span class="preprocessor">#if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1</span></div>
<div class="line"> log.hfill_mark( <span class="charliteral">&#39;_&#39;</span> );</div>
<div class="line"><span class="preprocessor">#endif </span></div>
</div><!-- fragment --><h3>Dependencies</h3>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md23"></a>
Dependencies</h3>
<p>Some colors/styles may not be supported by some exotic terminal emulators.</p>
<p>Clutchlog needs <code>C++-17</code> with the <code>filesystem</code> feature. You may need to indicate <code>-std=c++17 -lstdc++fs</code> to some compilers.</p>
<h3>Variable names within the CLUTCHLOG macro</h3>
<h3><a class="anchor" id="autotoc_md24"></a>
Variable names within the CLUTCHLOG macro</h3>
<p>Calling the <code>CLUTCHLOG</code> macro with a message using a variable named <code>clutchlog__msg</code> will end in an error.</p>
<h3>Features</h3>
<h3><a class="anchor" id="autotoc_md25"></a>
Features</h3>
<p>What Clutchlog do not provide at the moment (but may in a near future):</p>
<ul>
<li>Super fast log writing.</li>
@ -370,7 +414,7 @@ Limitations</h1>
<li>Automatic argument parser (please, use a dedicated lib).</li>
<li>Signal handling (WTF would you do that, anyway?).</li>
</ul>
<h1><a class="anchor" id="autotoc_md17"></a>
<h1><a class="anchor" id="autotoc_md26"></a>
Build and tests</h1>
<p>To use clutchlog, just include its header in your code and either ensure that the <code>NDEBUG</code> preprocessor variable is not set, either define the <code>WITH_CLUTCHLOG</code> preprocessor variable.</p>
<p>If you're using CMake (or another modern build system), it will unset <code>NDEBUG</code> —and thus enable clutchlog— only for the "Debug" build type, which is usually what you want if you use clutchlog, anyway.</p>
@ -382,21 +426,24 @@ Build and tests</h1>
</div><!-- fragment --><p>There's a script that tests all the build types combinations: <code>./build_all.sh</code>. </p>
</div></div><!-- PageDoc -->
</div><!-- contents -->
<div class="ttc" id="agroup__UseMacros_html_ga6f86187e2b35e7e1907d688f504a197d"><div class="ttname"><a href="group__UseMacros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a></div><div class="ttdeci">#define CLUTCHLOG(LEVEL, WHAT)</div><div class="ttdoc">Log a message at the given level.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:81</div></div>
</div><!-- doc-content -->
<div class="ttc" id="agroup___default_config_html_ga45c4c964fad4ad1641d5c9c28c4645b9"><div class="ttname"><a href="group___default_config.html#ga45c4c964fad4ad1641d5c9c28c4645b9">CLUTCHLOG_DEFAULT_DEPTH_MARK</a></div><div class="ttdeci">#define CLUTCHLOG_DEFAULT_DEPTH_MARK</div><div class="ttdoc">Compile-time default mark for stack depth.</div><div class="ttdef"><b>Definition:</b> <a href="clutchlog_8h_source.html#l00246">clutchlog.h:246</a></div></div>
<div class="ttc" id="aclassclutchlog_1_1fmt_html_a2bb0fde65fcd264393e102314dd1610b"><div class="ttname"><a href="classclutchlog_1_1fmt.html#a2bb0fde65fcd264393e102314dd1610b">clutchlog::fmt::style</a></div><div class="ttdeci">enum clutchlog::fmt::typo style</div><div class="ttdoc">Typographic style.</div></div>
<div class="ttc" id="agroup__UseMacros_html_gae8911119d726a43b77f5781cb5a72813"><div class="ttname"><a href="group__UseMacros.html#gae8911119d726a43b77f5781cb5a72813">CLUTCHLOC</a></div><div class="ttdeci">#define CLUTCHLOC</div><div class="ttdoc">Handy shortcuts to location.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:77</div></div>
<div class="ttc" id="agroup__UseMacros_html_gaaf2e85e1153e6c88b458dd49e3c37c73"><div class="ttname"><a href="group__UseMacros.html#gaaf2e85e1153e6c88b458dd49e3c37c73">CLUTCHCODE</a></div><div class="ttdeci">#define CLUTCHCODE(LEVEL,...)</div><div class="ttdoc">Run any code if the scope matches.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:136</div></div>
<div class="ttc" id="agroup__DefaultConfig_html_ga45c4c964fad4ad1641d5c9c28c4645b9"><div class="ttname"><a href="group__DefaultConfig.html#ga45c4c964fad4ad1641d5c9c28c4645b9">CLUTCHLOG_DEFAULT_DEPTH_MARK</a></div><div class="ttdeci">#define CLUTCHLOG_DEFAULT_DEPTH_MARK</div><div class="ttdoc">Compile-time default mark for stack depth.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:246</div></div>
<div class="ttc" id="aclassclutchlog_html_acfaceb77da01503b432644a3efaee4fa"><div class="ttname"><a href="classclutchlog.html#acfaceb77da01503b432644a3efaee4fa">clutchlog::logger</a></div><div class="ttdeci">static clutchlog &amp; logger()</div><div class="ttdoc">Get the logger instance.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:291</div></div>
<div class="ttc" id="aclassclutchlog_1_1fmt_html"><div class="ttname"><a href="classclutchlog_1_1fmt.html">clutchlog::fmt</a></div><div class="ttdoc">Color and style formatter for ANSI terminal escape sequences.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:309</div></div>
<div class="ttc" id="agroup__DefaultConfig_html_ga98f30d814d4913a8a7c93a8793f49adf"><div class="ttname"><a href="group__DefaultConfig.html#ga98f30d814d4913a8a7c93a8793f49adf">CLUTCHLOG_STRIP_CALLS</a></div><div class="ttdeci">#define CLUTCHLOG_STRIP_CALLS</div><div class="ttdoc">Compile-time number of call stack levels to remove from depth display by default.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:253</div></div>
<div class="ttc" id="agroup__UseMacros_html_ga572e3aa19d8b39e3ed0b9e91961104c2"><div class="ttname"><a href="group__UseMacros.html#ga572e3aa19d8b39e3ed0b9e91961104c2">CLUTCHDUMP</a></div><div class="ttdeci">#define CLUTCHDUMP(LEVEL, CONTAINER, FILENAME)</div><div class="ttdoc">Dump the given container.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:98</div></div>
<div class="ttc" id="agroup__UseMacros_html_ga9f77cee4f853e582262930c9c17f90ae"><div class="ttname"><a href="group__UseMacros.html#ga9f77cee4f853e582262930c9c17f90ae">CLUTCHFUNC</a></div><div class="ttdeci">#define CLUTCHFUNC(LEVEL, FUNC,...)</div><div class="ttdoc">Call any function if the scope matches.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:115</div></div>
<div class="ttc" id="agroup___use_macros_html_ga572e3aa19d8b39e3ed0b9e91961104c2"><div class="ttname"><a href="group___use_macros.html#ga572e3aa19d8b39e3ed0b9e91961104c2">CLUTCHDUMP</a></div><div class="ttdeci">#define CLUTCHDUMP(LEVEL, CONTAINER, FILENAME)</div><div class="ttdoc">Dump the given container.</div><div class="ttdef"><b>Definition:</b> <a href="clutchlog_8h_source.html#l00098">clutchlog.h:98</a></div></div>
<div class="ttc" id="aclassclutchlog_html_acfaceb77da01503b432644a3efaee4fa"><div class="ttname"><a href="classclutchlog.html#acfaceb77da01503b432644a3efaee4fa">clutchlog::logger</a></div><div class="ttdeci">static clutchlog &amp; logger()</div><div class="ttdoc">Get the logger instance.</div><div class="ttdef"><b>Definition:</b> <a href="clutchlog_8h_source.html#l00291">clutchlog.h:291</a></div></div>
<div class="ttc" id="aclassclutchlog_1_1fmt_html"><div class="ttname"><a href="classclutchlog_1_1fmt.html">clutchlog::fmt</a></div><div class="ttdoc">Color and style formatter for ANSI terminal escape sequences.</div><div class="ttdef"><b>Definition:</b> <a href="clutchlog_8h_source.html#l00309">clutchlog.h:309</a></div></div>
<div class="ttc" id="agroup___use_macros_html_gae8911119d726a43b77f5781cb5a72813"><div class="ttname"><a href="group___use_macros.html#gae8911119d726a43b77f5781cb5a72813">CLUTCHLOC</a></div><div class="ttdeci">#define CLUTCHLOC</div><div class="ttdoc">Handy shortcuts to location.</div><div class="ttdef"><b>Definition:</b> <a href="clutchlog_8h_source.html#l00077">clutchlog.h:77</a></div></div>
<div class="ttc" id="agroup___use_macros_html_ga6f86187e2b35e7e1907d688f504a197d"><div class="ttname"><a href="group___use_macros.html#ga6f86187e2b35e7e1907d688f504a197d">CLUTCHLOG</a></div><div class="ttdeci">#define CLUTCHLOG(LEVEL, WHAT)</div><div class="ttdoc">Log a message at the given level.</div><div class="ttdef"><b>Definition:</b> <a href="clutchlog_8h_source.html#l00081">clutchlog.h:81</a></div></div>
<div class="ttc" id="agroup___use_macros_html_ga9f77cee4f853e582262930c9c17f90ae"><div class="ttname"><a href="group___use_macros.html#ga9f77cee4f853e582262930c9c17f90ae">CLUTCHFUNC</a></div><div class="ttdeci">#define CLUTCHFUNC(LEVEL, FUNC,...)</div><div class="ttdoc">Call any function if the scope matches.</div><div class="ttdef"><b>Definition:</b> <a href="clutchlog_8h_source.html#l00115">clutchlog.h:115</a></div></div>
<div class="ttc" id="agroup___default_config_html_ga98f30d814d4913a8a7c93a8793f49adf"><div class="ttname"><a href="group___default_config.html#ga98f30d814d4913a8a7c93a8793f49adf">CLUTCHLOG_STRIP_CALLS</a></div><div class="ttdeci">#define CLUTCHLOG_STRIP_CALLS</div><div class="ttdoc">Compile-time number of call stack levels to remove from depth display by default.</div><div class="ttdef"><b>Definition:</b> <a href="clutchlog_8h_source.html#l00253">clutchlog.h:253</a></div></div>
<div class="ttc" id="agroup___use_macros_html_gaaf2e85e1153e6c88b458dd49e3c37c73"><div class="ttname"><a href="group___use_macros.html#gaaf2e85e1153e6c88b458dd49e3c37c73">CLUTCHCODE</a></div><div class="ttdeci">#define CLUTCHCODE(LEVEL,...)</div><div class="ttdoc">Run any code if the scope matches.</div><div class="ttdef"><b>Definition:</b> <a href="clutchlog_8h_source.html#l00136">clutchlog.h:136</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.17 </li>
</ul>
</div>
</body>
</html>