fix {depth} display, warnings and doc

- fix call stack depth display with {depth}: remove (5) stripped depths.
- fix warnings in tests
- Explain CLUTCHLOG_HAVE_UNIX_SYSINFO in the README.
This commit is contained in:
Johann Dreo 2021-12-19 08:30:19 +01:00
commit 44ffe6309a
4 changed files with 63 additions and 2 deletions

View file

@ -26,6 +26,7 @@ namespace fs = std::filesystem;
#include <execinfo.h> // execinfo
#include <stdlib.h> // getenv
#include <libgen.h> // basename
//! POSIX headers necessary for stack depth management are available.
#define CLUTCHLOG_HAVE_UNIX_SYSINFO 1
#else
#define CLUTCHLOG_HAVE_UNIX_SYSINFO 0
@ -36,6 +37,7 @@ namespace fs = std::filesystem;
**********************************************************************/
#ifndef WITH_CLUTCHLOG
#ifndef NDEBUG
//! Actually enable clutchlog features.
#define WITH_CLUTCHLOG
#endif
#endif
@ -662,7 +664,7 @@ class clutchlog
#if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
format = replace(format, "\\{name\\}", name);
format = replace(format, "\\{depth\\}", depth);
format = replace(format, "\\{depth\\}", depth - _strip_calls);
std::ostringstream chevrons;
for(size_t i = _strip_calls; i < depth; ++i) {