diff --git a/README.md b/README.md index c9893f5..e9d0d3c 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,10 @@ and its default with the `CLUTCHLOG_DEFAULT_DEPTH_MARK` macro: log.depth_mark(CLUTCHLOG_DEFAULT_DEPTH_MARK); // Defaults to ">". ``` +By default, clutchlog removes 5 levels of the calls stack, so that your `main` +entrypoint corresponds to a depth of zero. +You can change this behaviour by defining the `CLUTCHLOG_STRIP_CALLS` macro. + Output style ------------ diff --git a/clutchlog/clutchlog.h b/clutchlog/clutchlog.h index 9a2fd9e..8120717 100644 --- a/clutchlog/clutchlog.h +++ b/clutchlog/clutchlog.h @@ -83,6 +83,10 @@ namespace fs = std::filesystem; #define CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG clutchlog::level::progress #endif // CLUTCHLOG_DEFAULT_DEPTH_BUILT +#ifndef CLUTCHLOG_STRIP_CALLS +//! Number of call stack levels to remove from depth display by default. +#define CLUTCHLOG_STRIP_CALLS 5 +#endif // CLUTCHLOG_STRIP_CALLS /** @} */ /** @addtogroup UseMacros High-level API macros @@ -343,7 +347,7 @@ class clutchlog private: clutchlog() : // system, main, log - _strip_calls(5), + _strip_calls(CLUTCHLOG_STRIP_CALLS), _level_word({ {level::critical,"Critical"}, {level::error ,"Error"}, diff --git a/docs/classclutchlog.html b/docs/classclutchlog.html index 9893573..29852e8 100644 --- a/docs/classclutchlog.html +++ b/docs/classclutchlog.html @@ -385,8 +385,8 @@ template<class ... FMT>
Note: the log levels constants are lower case (for example: clutchlog::level::xdebug), but their string representation is not (e.g. "XDebug", this should be taken into account when using level_of).
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: execinfo.h, stdlib.h and libgen.h (so far, tested with Linux).
Clutchlog sets the CLUTCHLOG_HAVE_UNIX_SYSINFO to 1 if the headers are available, and to 0 if they are not. You can make portable code using something like:
Some colors/styles may not be supported by some exotic terminal emulators.
Clutchlog needs C++-17 with the filesystem feature. You may need to indicate -std=c++17 -lstdc++fs to some compilers.
What Clutchlog do not provide at the moment (but may in a near future):
There's a script which tests all the build types combinations: ./build_all.sh.