fix: const correctness

This commit is contained in:
Johann Dreo 2022-09-01 22:55:13 +02:00
commit 1822209cb9
14 changed files with 829 additions and 781 deletions

View file

@ -471,7 +471,7 @@ class clutchlog
/** Current format of the file output. */
std::string _format_dump;
/** Character for filling. */
const char _hfill_char;
char _hfill_char;
/** Standard output. */
std::ostream* _out;
#if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
@ -794,11 +794,11 @@ class clutchlog
const size_t right_len = format.size() - hfill_pos - hfill_tag.size();
if(right_len+left_len > _nb_columns) {
// The right part would go over the terminal width: add a new line.
const std::string hfill(std::max(0, _nb_columns-right_len), _hfill_char);
const std::string hfill(std::max((size_t)0, _nb_columns-right_len), _hfill_char);
format = replace(format, "\\{hfill\\}", "\n"+hfill);
} else {
// There is some space in between left and right parts.
const std::string hfill(std::max(0, _nb_columns - (right_len+left_len)), _hfill_char);
const std::string hfill(std::max((size_t)0, _nb_columns - (right_len+left_len)), _hfill_char);
format = replace(format, "\\{hfill\\}", hfill);
}
} else {

View file

@ -71,7 +71,7 @@ $(function() {
<table class="directory">
<tr class="even"><td class="entry"><a class="el" href="group__UseMacros.html#ga5f4ddb57ce42e8be86a7c7d269f7bae5">_format_dump</a></td><td class="entry"><a class="el" href="classclutchlog.html">clutchlog</a></td><td class="entry"><span class="mlabel">protected</span></td></tr>
<tr><td class="entry"><a class="el" href="group__UseMacros.html#ga7c6e3fc082bc6f55d50131ed2b32e81e">_format_log</a></td><td class="entry"><a class="el" href="classclutchlog.html">clutchlog</a></td><td class="entry"><span class="mlabel">protected</span></td></tr>
<tr class="even"><td class="entry"><a class="el" href="group__UseMacros.html#ga9e34e90eef755241f6cd9394b4a32d71">_hfill_char</a></td><td class="entry"><a class="el" href="classclutchlog.html">clutchlog</a></td><td class="entry"><span class="mlabel">protected</span></td></tr>
<tr class="even"><td class="entry"><a class="el" href="group__UseMacros.html#gae24e7530a131344f53e3e794b913845a">_hfill_char</a></td><td class="entry"><a class="el" href="classclutchlog.html">clutchlog</a></td><td class="entry"><span class="mlabel">protected</span></td></tr>
<tr><td class="entry"><a class="el" href="group__UseMacros.html#gaded03528f34d9000f618419c482c5042">_in_file</a></td><td class="entry"><a class="el" href="classclutchlog.html">clutchlog</a></td><td class="entry"><span class="mlabel">protected</span></td></tr>
<tr class="even"><td class="entry"><a class="el" href="group__UseMacros.html#ga130c4f12eacbd2028102838fe16b734e">_in_func</a></td><td class="entry"><a class="el" href="classclutchlog.html">clutchlog</a></td><td class="entry"><span class="mlabel">protected</span></td></tr>
<tr><td class="entry"><a class="el" href="group__UseMacros.html#ga41757198b29862832a14472a9e5e24c6">_in_line</a></td><td class="entry"><a class="el" href="classclutchlog.html">clutchlog</a></td><td class="entry"><span class="mlabel">protected</span></td></tr>

View file

@ -203,7 +203,7 @@ static unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class=
<tr class="memdesc:ga1a8cb6411726133208f5a2f2cb42d468"><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of call stack levels to remove from depth display by default. <br /></td></tr>
<tr class="separator:ga1a8cb6411726133208f5a2f2cb42d468"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga76eb34537b634aadb75e255f7887eeb6"><td class="memItemLeft" align="right" valign="top">
static char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga76eb34537b634aadb75e255f7887eeb6">default_hfill_char</a> = <a class="el" href="group__UseMacros.html#ga763fb5aa1ca3012c142ddaa6707e3fde">CLUTCHLOG_HFILL_CHAR</a></td></tr>
static char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga76eb34537b634aadb75e255f7887eeb6">default_hfill_char</a> = <a class="el" href="group__UseMacros.html#gad5fbbacf74b8e4669b8f9efdfe81bd25">CLUTCHLOG_HFILL_MARK</a></td></tr>
<tr class="memdesc:ga76eb34537b634aadb75e255f7887eeb6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default character used as a filling for right-align the right part of messages with "{hfill}". <br /></td></tr>
<tr class="separator:ga76eb34537b634aadb75e255f7887eeb6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
@ -253,10 +253,10 @@ std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" hre
std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga5f4ddb57ce42e8be86a7c7d269f7bae5">_format_dump</a></td></tr>
<tr class="memdesc:ga5f4ddb57ce42e8be86a7c7d269f7bae5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Current format of the file output. <br /></td></tr>
<tr class="separator:ga5f4ddb57ce42e8be86a7c7d269f7bae5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9e34e90eef755241f6cd9394b4a32d71"><td class="memItemLeft" align="right" valign="top">
const char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga9e34e90eef755241f6cd9394b4a32d71">_hfill_char</a></td></tr>
<tr class="memdesc:ga9e34e90eef755241f6cd9394b4a32d71"><td class="mdescLeft">&#160;</td><td class="mdescRight">Character for filling. <br /></td></tr>
<tr class="separator:ga9e34e90eef755241f6cd9394b4a32d71"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae24e7530a131344f53e3e794b913845a"><td class="memItemLeft" align="right" valign="top">
char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#gae24e7530a131344f53e3e794b913845a">_hfill_char</a></td></tr>
<tr class="memdesc:gae24e7530a131344f53e3e794b913845a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Character for filling. <br /></td></tr>
<tr class="separator:gae24e7530a131344f53e3e794b913845a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1896f6c4b8597e3e76ff93970bd85167"><td class="memItemLeft" align="right" valign="top">
std::ostream *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga1896f6c4b8597e3e76ff93970bd85167">_out</a></td></tr>
<tr class="memdesc:ga1896f6c4b8597e3e76ff93970bd85167"><td class="mdescLeft">&#160;</td><td class="mdescRight">Standard output. <br /></td></tr>

View file

@ -170,10 +170,10 @@ Macros</h2></td></tr>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga98f30d814d4913a8a7c93a8793f49adf">CLUTCHLOG_STRIP_CALLS</a>&#160;&#160;&#160;5</td></tr>
<tr class="memdesc:ga98f30d814d4913a8a7c93a8793f49adf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compile-time number of call stack levels to remove from depth display by default. <br /></td></tr>
<tr class="separator:ga98f30d814d4913a8a7c93a8793f49adf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga763fb5aa1ca3012c142ddaa6707e3fde"><td class="memItemLeft" align="right" valign="top">
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga763fb5aa1ca3012c142ddaa6707e3fde">CLUTCHLOG_HFILL_CHAR</a>&#160;&#160;&#160;'.'</td></tr>
<tr class="memdesc:ga763fb5aa1ca3012c142ddaa6707e3fde"><td class="mdescLeft">&#160;</td><td class="mdescRight">Character used as a filling for right-align the right part of messages with "{hfill}". <br /></td></tr>
<tr class="separator:ga763fb5aa1ca3012c142ddaa6707e3fde"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad5fbbacf74b8e4669b8f9efdfe81bd25"><td class="memItemLeft" align="right" valign="top">
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#gad5fbbacf74b8e4669b8f9efdfe81bd25">CLUTCHLOG_HFILL_MARK</a>&#160;&#160;&#160;'.'</td></tr>
<tr class="memdesc:gad5fbbacf74b8e4669b8f9efdfe81bd25"><td class="mdescLeft">&#160;</td><td class="mdescRight">Character used as a filling for right-align the right part of messages with "{hfill}". <br /></td></tr>
<tr class="separator:gad5fbbacf74b8e4669b8f9efdfe81bd25"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
<!-- start footer part -->

File diff suppressed because it is too large Load diff

View file

@ -72,7 +72,7 @@ $(function() {
: <a class="el" href="group__UseMacros.html#ga7c6e3fc082bc6f55d50131ed2b32e81e">clutchlog</a>
</li>
<li>_hfill_char
: <a class="el" href="group__UseMacros.html#ga9e34e90eef755241f6cd9394b4a32d71">clutchlog</a>
: <a class="el" href="group__UseMacros.html#gae24e7530a131344f53e3e794b913845a">clutchlog</a>
</li>
<li>_in_file
: <a class="el" href="group__UseMacros.html#gaded03528f34d9000f618419c482c5042">clutchlog</a>

View file

@ -70,7 +70,7 @@ $(function() {
: <a class="el" href="group__UseMacros.html#ga7c6e3fc082bc6f55d50131ed2b32e81e">clutchlog</a>
</li>
<li>_hfill_char
: <a class="el" href="group__UseMacros.html#ga9e34e90eef755241f6cd9394b4a32d71">clutchlog</a>
: <a class="el" href="group__UseMacros.html#gae24e7530a131344f53e3e794b913845a">clutchlog</a>
</li>
<li>_in_file
: <a class="el" href="group__UseMacros.html#gaded03528f34d9000f618419c482c5042">clutchlog</a>

View file

@ -96,8 +96,8 @@ $(function() {
<li>CLUTCHLOG_HAVE_UNIX_SYSINFO
: <a class="el" href="clutchlog_8h.html#a6bbcf13504687db4dbe0474931d867fb">clutchlog.h</a>
</li>
<li>CLUTCHLOG_HFILL_CHAR
: <a class="el" href="group__UseMacros.html#ga763fb5aa1ca3012c142ddaa6707e3fde">clutchlog.h</a>
<li>CLUTCHLOG_HFILL_MARK
: <a class="el" href="group__UseMacros.html#gad5fbbacf74b8e4669b8f9efdfe81bd25">clutchlog.h</a>
</li>
<li>CLUTCHLOG_STRIP_CALLS
: <a class="el" href="group__UseMacros.html#ga98f30d814d4913a8a7c93a8793f49adf">clutchlog.h</a>

View file

@ -96,8 +96,8 @@ $(function() {
<li>CLUTCHLOG_HAVE_UNIX_SYSINFO
: <a class="el" href="clutchlog_8h.html#a6bbcf13504687db4dbe0474931d867fb">clutchlog.h</a>
</li>
<li>CLUTCHLOG_HFILL_CHAR
: <a class="el" href="group__UseMacros.html#ga763fb5aa1ca3012c142ddaa6707e3fde">clutchlog.h</a>
<li>CLUTCHLOG_HFILL_MARK
: <a class="el" href="group__UseMacros.html#gad5fbbacf74b8e4669b8f9efdfe81bd25">clutchlog.h</a>
</li>
<li>CLUTCHLOG_STRIP_CALLS
: <a class="el" href="group__UseMacros.html#ga98f30d814d4913a8a7c93a8793f49adf">clutchlog.h</a>

View file

@ -134,10 +134,10 @@ Macros</h2></td></tr>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga98f30d814d4913a8a7c93a8793f49adf">CLUTCHLOG_STRIP_CALLS</a>&#160;&#160;&#160;5</td></tr>
<tr class="memdesc:ga98f30d814d4913a8a7c93a8793f49adf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compile-time number of call stack levels to remove from depth display by default. <br /></td></tr>
<tr class="separator:ga98f30d814d4913a8a7c93a8793f49adf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga763fb5aa1ca3012c142ddaa6707e3fde"><td class="memItemLeft" align="right" valign="top"><a id="ga763fb5aa1ca3012c142ddaa6707e3fde"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga763fb5aa1ca3012c142ddaa6707e3fde">CLUTCHLOG_HFILL_CHAR</a>&#160;&#160;&#160;'.'</td></tr>
<tr class="memdesc:ga763fb5aa1ca3012c142ddaa6707e3fde"><td class="mdescLeft">&#160;</td><td class="mdescRight">Character used as a filling for right-align the right part of messages with "{hfill}". <br /></td></tr>
<tr class="separator:ga763fb5aa1ca3012c142ddaa6707e3fde"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad5fbbacf74b8e4669b8f9efdfe81bd25"><td class="memItemLeft" align="right" valign="top"><a id="gad5fbbacf74b8e4669b8f9efdfe81bd25"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#gad5fbbacf74b8e4669b8f9efdfe81bd25">CLUTCHLOG_HFILL_MARK</a>&#160;&#160;&#160;'.'</td></tr>
<tr class="memdesc:gad5fbbacf74b8e4669b8f9efdfe81bd25"><td class="mdescLeft">&#160;</td><td class="mdescRight">Character used as a filling for right-align the right part of messages with "{hfill}". <br /></td></tr>
<tr class="separator:gad5fbbacf74b8e4669b8f9efdfe81bd25"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
@ -226,7 +226,7 @@ static unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class=
<tr class="memdesc:ga1a8cb6411726133208f5a2f2cb42d468"><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of call stack levels to remove from depth display by default. <br /></td></tr>
<tr class="separator:ga1a8cb6411726133208f5a2f2cb42d468"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga76eb34537b634aadb75e255f7887eeb6"><td class="memItemLeft" align="right" valign="top"><a id="ga76eb34537b634aadb75e255f7887eeb6"></a>
static char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga76eb34537b634aadb75e255f7887eeb6">clutchlog::default_hfill_char</a> = <a class="el" href="group__UseMacros.html#ga763fb5aa1ca3012c142ddaa6707e3fde">CLUTCHLOG_HFILL_CHAR</a></td></tr>
static char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga76eb34537b634aadb75e255f7887eeb6">clutchlog::default_hfill_char</a> = <a class="el" href="group__UseMacros.html#gad5fbbacf74b8e4669b8f9efdfe81bd25">CLUTCHLOG_HFILL_MARK</a></td></tr>
<tr class="memdesc:ga76eb34537b634aadb75e255f7887eeb6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default character used as a filling for right-align the right part of messages with "{hfill}". <br /></td></tr>
<tr class="separator:ga76eb34537b634aadb75e255f7887eeb6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8307a848fcf9ed929435b3e1f2b53401"><td class="memItemLeft" align="right" valign="top"><a id="ga8307a848fcf9ed929435b3e1f2b53401"></a>
@ -306,10 +306,10 @@ std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" hre
std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga5f4ddb57ce42e8be86a7c7d269f7bae5">clutchlog::_format_dump</a></td></tr>
<tr class="memdesc:ga5f4ddb57ce42e8be86a7c7d269f7bae5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Current format of the file output. <br /></td></tr>
<tr class="separator:ga5f4ddb57ce42e8be86a7c7d269f7bae5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9e34e90eef755241f6cd9394b4a32d71"><td class="memItemLeft" align="right" valign="top"><a id="ga9e34e90eef755241f6cd9394b4a32d71"></a>
const char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga9e34e90eef755241f6cd9394b4a32d71">clutchlog::_hfill_char</a></td></tr>
<tr class="memdesc:ga9e34e90eef755241f6cd9394b4a32d71"><td class="mdescLeft">&#160;</td><td class="mdescRight">Character for filling. <br /></td></tr>
<tr class="separator:ga9e34e90eef755241f6cd9394b4a32d71"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae24e7530a131344f53e3e794b913845a"><td class="memItemLeft" align="right" valign="top"><a id="gae24e7530a131344f53e3e794b913845a"></a>
char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#gae24e7530a131344f53e3e794b913845a">clutchlog::_hfill_char</a></td></tr>
<tr class="memdesc:gae24e7530a131344f53e3e794b913845a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Character for filling. <br /></td></tr>
<tr class="separator:gae24e7530a131344f53e3e794b913845a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1896f6c4b8597e3e76ff93970bd85167"><td class="memItemLeft" align="right" valign="top"><a id="ga1896f6c4b8597e3e76ff93970bd85167"></a>
std::ostream *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__UseMacros.html#ga1896f6c4b8597e3e76ff93970bd85167">clutchlog::_out</a></td></tr>
<tr class="memdesc:ga1896f6c4b8597e3e76ff93970bd85167"><td class="mdescLeft">&#160;</td><td class="mdescRight">Standard output. <br /></td></tr>
@ -837,11 +837,11 @@ template&lt;class ... FMT&gt; </div>
</div>
</div>
</div><!-- contents -->
<div class="ttc" id="agroup__UseMacros_html_gacfaceb77da01503b432644a3efaee4fa"><div class="ttname"><a href="group__UseMacros.html#gacfaceb77da01503b432644a3efaee4fa">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:262</div></div>
<div class="ttc" id="agroup__UseMacros_html_ga54d29e956575e1c731eab5406135c5df"><div class="ttname"><a href="group__UseMacros.html#ga54d29e956575e1c731eab5406135c5df">CLUTCHDUMP_DEFAULT_SEP</a></div><div class="ttdeci">#define CLUTCHDUMP_DEFAULT_SEP</div><div class="ttdoc">Compile-time default item separator for dump.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:224</div></div>
<div class="ttc" id="agroup__UseMacros_html_ga23dbb98f0d3c5cc21c232cde16cf317a"><div class="ttname"><a href="group__UseMacros.html#ga23dbb98f0d3c5cc21c232cde16cf317a">clutchlog::log</a></div><div class="ttdeci">void log(const level &amp;stage, const std::string &amp;what, const std::string &amp;file, const std::string &amp;func, size_t line) const</div><div class="ttdoc">Print a log message IF the location matches the given one.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:790</div></div>
<div class="ttc" id="agroup__UseMacros_html_gacfaceb77da01503b432644a3efaee4fa"><div class="ttname"><a href="group__UseMacros.html#gacfaceb77da01503b432644a3efaee4fa">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:273</div></div>
<div class="ttc" id="agroup__UseMacros_html_ga54d29e956575e1c731eab5406135c5df"><div class="ttname"><a href="group__UseMacros.html#ga54d29e956575e1c731eab5406135c5df">CLUTCHDUMP_DEFAULT_SEP</a></div><div class="ttdeci">#define CLUTCHDUMP_DEFAULT_SEP</div><div class="ttdoc">Compile-time default item separator for dump.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:235</div></div>
<div class="ttc" id="agroup__UseMacros_html_ga23dbb98f0d3c5cc21c232cde16cf317a"><div class="ttname"><a href="group__UseMacros.html#ga23dbb98f0d3c5cc21c232cde16cf317a">clutchlog::log</a></div><div class="ttdeci">void log(const level &amp;stage, const std::string &amp;what, const std::string &amp;file, const std::string &amp;func, size_t line) const</div><div class="ttdoc">Print a log message IF the location matches the given one.</div><div class="ttdef"><b>Definition:</b> clutchlog.h:814</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:75</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:283</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:294</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">

View file

@ -74,18 +74,23 @@ $(function() {
<li class="level2"><a href="#autotoc_md5">Calls</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_md9">Disabled calls</a></li>
<li class="level2"><a href="#autotoc_md10">Low-level API</a></li>
<li class="level2"><a href="#autotoc_md11">(De)clutch any function call</a></li>
<li class="level2"><a href="#autotoc_md12">(De)clutch any code section</a></li>
<li class="level2"><a href="#autotoc_md8">Stack Depth</a></li>
<li class="level2"><a href="#autotoc_md9">Output style</a></li>
<li class="level2"><a href="#autotoc_md10">Disabled calls</a></li>
<li class="level2"><a href="#autotoc_md11">Low-level API</a></li>
<li class="level2"><a href="#autotoc_md12">(De)clutch any function call</a></li>
<li class="level2"><a href="#autotoc_md13">(De)clutch any code section</a></li>
</ul>
</li>
<li class="level1"><a href="#autotoc_md13">Limitations</a></li>
<li class="level1"><a href="#autotoc_md14">Build and tests</a></li>
<li class="level1"><a href="#autotoc_md14">Limitations</a></li>
<li class="level1"><a href="#autotoc_md15">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>
<ul>
<li><a href="https://github.com/nojhan/clutchlog">Project page on Github</a></li>
<li><a href="https://nojhan.github.io/clutchlog/">Documentation</a></li>
</ul>
<p><object type="image/svg+xml" data="https://raw.githubusercontent.com/nojhan/clutchlog/master/docs/clutchlog_logo.svg" style="pointer-events: none;">Clutchlog logo</object></p>
<h1><a class="anchor" id="autotoc_md0"></a>
Features</h1>
@ -174,20 +179,33 @@ Output Configuration</h2>
</div><!-- fragment --><p>Available tags are:</p>
<ul>
<li><code>{msg}</code>: the logged message,</li>
<li><code>{name}</code>: the name of the current binary,</li>
<li><code>{level}</code>: the current log level (i.e. <code>Critical</code>, <code>Error</code>, <code>Warning</code>, <code>Progress</code>, <code>Note</code>, <code>Info</code>, <code>Debug</code> or <code>XDebug</code>),</li>
<li><code>{level_letter}</code>: the first letter of the current log level,</li>
<li><code>{file}</code>: the current file (absolute path),</li>
<li><code>{func}</code>: the current function,</li>
<li><code>{line}</code>: the current line number,</li>
<li><code>{depth}</code>: the current depth of the call stack,</li>
<li><code>{depth_marks}</code>: as many chevrons <code>&gt;</code> as there is calls in the stack.</li>
<li><code>{line}</code>: the current line number.</li>
</ul>
<p>The default log format is <code>"[{name}] {level_letter}:{depth_marks} {msg}\t\t\t\t\t{func} @ {file}:{line}\n"</code>, it can be overriden at compile time by defining the <code>CLUTCHLOG_DEFAULT_FORMAT</code> macro.</p>
<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>. 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>Some tags are only available on POSIX operating systems as of now:</p><ul>
<li><code>{name}</code>: the name of the current binary,</li>
<li><code>{depth}</code>: the current depth of the call stack,</li>
<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>
<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>
<h3>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>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__UseMacros.html#ga45c4c964fad4ad1641d5c9c28c4645b9">CLUTCHLOG_DEFAULT_DEPTH_MARK</a>); <span class="comment">// Defaults to &quot;&gt;&quot;.</span></div>
</div><!-- fragment --><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.</p>
</div><!-- fragment --><p>The character used with the <code>{hfill}</code> tag can be configured wth the <code>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>Note: if the system detects no terminal, only a single fill character is inserted.</p>
<h2><a class="anchor" id="autotoc_md8"></a>
Stack Depth</h2>
<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.</p>
<h2><a class="anchor" id="autotoc_md9"></a>
Output style</h2>
<p>The output 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>
@ -233,7 +251,7 @@ Output style</h2>
<div class="line"> &lt;&lt; fmt(fmt::typo::reset) &lt;&lt; <span class="stringliteral">&quot; {msg}&quot;</span> &lt;&lt; std::endl; <span class="comment">// This is a reset.</span></div>
<div class="line">log.format(format.str());</div>
</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>
<h2><a class="anchor" id="autotoc_md9"></a>
<h2><a class="anchor" id="autotoc_md10"></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>
@ -242,7 +260,7 @@ 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_md10"></a>
<h2><a class="anchor" id="autotoc_md11"></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>log</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>
@ -250,29 +268,34 @@ Low-level API</h2>
</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 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>level_of</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_md11"></a>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md12"></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_md12"></a>
<h2><a class="anchor" id="autotoc_md13"></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>
<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_md13"></a>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md14"></a>
Limitations</h1>
<h3>System-dependent stack depth</h3>
<p>Because the call stack depth and program name access 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>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>
<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>
<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>
<p>Calling the <code>CLUTCHLOG</code> macro with a message using a variable named <code>clutchlog__msg</code> will end in an error. Avoid this kind of naming for the logger singleton, also.</p>
<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>
<p>What Clutchlog do not provide at the moment (but may in a near future):</p>
<ul>
@ -288,7 +311,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_md14"></a>
<h1><a class="anchor" id="autotoc_md15"></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>
@ -300,12 +323,12 @@ 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_gacfaceb77da01503b432644a3efaee4fa"><div class="ttname"><a href="group__UseMacros.html#gacfaceb77da01503b432644a3efaee4fa">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:262</div></div>
<div class="ttc" id="agroup__UseMacros_html_gacfaceb77da01503b432644a3efaee4fa"><div class="ttname"><a href="group__UseMacros.html#gacfaceb77da01503b432644a3efaee4fa">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:273</div></div>
<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:79</div></div>
<div class="ttc" id="agroup__UseMacros_html_ga45c4c964fad4ad1641d5c9c28c4645b9"><div class="ttname"><a href="group__UseMacros.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:231</div></div>
<div class="ttc" id="agroup__UseMacros_html_ga45c4c964fad4ad1641d5c9c28c4645b9"><div class="ttname"><a href="group__UseMacros.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:242</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:75</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:134</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:283</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:294</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:96</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>

View file

@ -2,7 +2,7 @@ var searchData=
[
['_5fformat_5fdump_0',['_format_dump',['../group__UseMacros.html#ga5f4ddb57ce42e8be86a7c7d269f7bae5',1,'clutchlog']]],
['_5fformat_5flog_1',['_format_log',['../group__UseMacros.html#ga7c6e3fc082bc6f55d50131ed2b32e81e',1,'clutchlog']]],
['_5fhfill_5fchar_2',['_hfill_char',['../group__UseMacros.html#ga9e34e90eef755241f6cd9394b4a32d71',1,'clutchlog']]],
['_5fhfill_5fchar_2',['_hfill_char',['../group__UseMacros.html#gae24e7530a131344f53e3e794b913845a',1,'clutchlog']]],
['_5fin_5ffile_3',['_in_file',['../group__UseMacros.html#gaded03528f34d9000f618419c482c5042',1,'clutchlog']]],
['_5fin_5ffunc_4',['_in_func',['../group__UseMacros.html#ga130c4f12eacbd2028102838fe16b734e',1,'clutchlog']]],
['_5fin_5fline_5',['_in_line',['../group__UseMacros.html#ga41757198b29862832a14472a9e5e24c6',1,'clutchlog']]],

View file

@ -12,7 +12,7 @@ var searchData=
['clutchlog_5fdefault_5fdepth_5fmark_23',['CLUTCHLOG_DEFAULT_DEPTH_MARK',['../group__UseMacros.html#ga45c4c964fad4ad1641d5c9c28c4645b9',1,'clutchlog.h']]],
['clutchlog_5fdefault_5fformat_24',['CLUTCHLOG_DEFAULT_FORMAT',['../group__UseMacros.html#ga524c16f280d92ee8ab683162c9ce01fa',1,'clutchlog.h']]],
['clutchlog_5fhave_5funix_5fsysinfo_25',['CLUTCHLOG_HAVE_UNIX_SYSINFO',['../clutchlog_8h.html#a6bbcf13504687db4dbe0474931d867fb',1,'clutchlog.h']]],
['clutchlog_5fhfill_5fchar_26',['CLUTCHLOG_HFILL_CHAR',['../group__UseMacros.html#ga763fb5aa1ca3012c142ddaa6707e3fde',1,'clutchlog.h']]],
['clutchlog_5fhfill_5fmark_26',['CLUTCHLOG_HFILL_MARK',['../group__UseMacros.html#gad5fbbacf74b8e4669b8f9efdfe81bd25',1,'clutchlog.h']]],
['clutchlog_5fstrip_5fcalls_27',['CLUTCHLOG_STRIP_CALLS',['../group__UseMacros.html#ga98f30d814d4913a8a7c93a8793f49adf',1,'clutchlog.h']]],
['clutchlog_20—_20versatile_20_28de_29clutchable_20logging_28',['Clutchlog — versatile (de)clutchable logging',['../index.html',1,'']]]
];

View file

@ -2,7 +2,7 @@ var searchData=
[
['_5fformat_5fdump_92',['_format_dump',['../group__UseMacros.html#ga5f4ddb57ce42e8be86a7c7d269f7bae5',1,'clutchlog']]],
['_5fformat_5flog_93',['_format_log',['../group__UseMacros.html#ga7c6e3fc082bc6f55d50131ed2b32e81e',1,'clutchlog']]],
['_5fhfill_5fchar_94',['_hfill_char',['../group__UseMacros.html#ga9e34e90eef755241f6cd9394b4a32d71',1,'clutchlog']]],
['_5fhfill_5fchar_94',['_hfill_char',['../group__UseMacros.html#gae24e7530a131344f53e3e794b913845a',1,'clutchlog']]],
['_5fin_5ffile_95',['_in_file',['../group__UseMacros.html#gaded03528f34d9000f618419c482c5042',1,'clutchlog']]],
['_5fin_5ffunc_96',['_in_func',['../group__UseMacros.html#ga130c4f12eacbd2028102838fe16b734e',1,'clutchlog']]],
['_5fin_5fline_97',['_in_line',['../group__UseMacros.html#ga41757198b29862832a14472a9e5e24c6',1,'clutchlog']]],