diff --git a/CMakeLists.txt b/CMakeLists.txt index 507a7f8..b794cc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) project("clutchlog" - VERSION 0.15 + VERSION 0.16 DESCRIPTION "A logging system which targets versatile debugging") enable_language(CXX) # C++ diff --git a/docs/annotated.html b/docs/annotated.html index c9f4a52..7a8cdd9 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -28,7 +28,7 @@ Logo
clutchlog -  0.14 +  0.15
diff --git a/docs/classclutchlog-members.html b/docs/classclutchlog-members.html index fe7c2cb..2fef3b8 100644 --- a/docs/classclutchlog-members.html +++ b/docs/classclutchlog-members.html @@ -28,7 +28,7 @@ Logo
clutchlog -  0.14 +  0.15
@@ -116,7 +116,7 @@ $(document).ready(function(){initNavTree('classclutchlog.html',''); initResizabl default_hfill_minclutchloginlineprotectedstatic default_strip_callsclutchloginlineprotectedstatic depth_styles(std::vector< fmt > styles)clutchloginline - dump(const level &stage, const In container_begin, const In container_end, const std::string &file, const std::string &func, size_t line, const std::string &filename_template="dump_{n}.dat", const std::string sep=dump_default_sep) constclutchloginline + dump(const level &stage, const In container_begin, const In container_end, const std::string &file, const std::string &func, const size_t line, const std::string &filename_template="dump_{n}.dat", const std::string sep=dump_default_sep) constclutchloginline dump_default_formatclutchloginlineprotectedstatic dump_default_sepclutchloginlineprotectedstatic error enum value (defined in clutchlog)clutchlog @@ -136,7 +136,7 @@ $(document).ready(function(){initNavTree('classclutchlog.html',''); initResizabl line(std::string line)clutchloginline locate(const level &stage, const std::string &file, const std::string &func, const size_t line) constclutchloginline location(const std::string &in_file, const std::string &in_function=".*", const std::string &in_line=".*")clutchloginline - log(const level &stage, const std::string &what, const std::string &file, const std::string &func, size_t line) constclutchloginline + log(const level &stage, const std::string &what, const std::string &file, const std::string &func, const size_t line, const size_t depth_delta=0) constclutchloginline logger()clutchloginlinestatic note enum value (defined in clutchlog)clutchlog operator=(clutchlog const &)=delete (defined in clutchlog)clutchlog diff --git a/docs/classclutchlog.html b/docs/classclutchlog.html index 299f623..907d2d3 100644 --- a/docs/classclutchlog.html +++ b/docs/classclutchlog.html @@ -28,7 +28,7 @@ Logo
clutchlog -  0.14 +  0.15
@@ -100,7 +100,7 @@ $(document).ready(function(){initNavTree('classclutchlog.html',''); initResizabl

The single class which holds everything.

This is a Singleton class.

-

Definition at line 177 of file clutchlog.h.

+

Definition at line 187 of file clutchlog.h.

@@ -201,15 +201,15 @@ std::string  - - - - + + + - - - + + +

Public Member Functions

format (std::string row, const std::string &what, const level &stage, const std::string &file, const std::string &func, const size_t line) const
 Substitute all tags in the format string with the corresponding information and apply the style corresponding to the log level.
 
-void log (const level &stage, const std::string &what, const std::string &file, const std::string &func, size_t line) const
 Print a log message IF the location matches the given one.
 
+
+void log (const level &stage, const std::string &what, const std::string &file, const std::string &func, const size_t line, const size_t depth_delta=0) const
 Print a log message IF the location matches the given one.
 
template<class In >
void dump (const level &stage, const In container_begin, const In container_end, const std::string &file, const std::string &func, size_t line, const std::string &filename_template="dump_{n}.dat", const std::string sep=dump_default_sep) const
 Dump a serializable container after a comment line with log information.
 
void dump (const level &stage, const In container_begin, const In container_end, const std::string &file, const std::string &func, const size_t line, const std::string &filename_template="dump_{n}.dat", const std::string sep=dump_default_sep) const
 Dump a serializable container after a comment line with log information.
 
@@ -369,9 +369,9 @@ void  diff --git a/docs/classclutchlog_1_1fmt.html b/docs/classclutchlog_1_1fmt.html index b1bb17c..4a78df2 100644 --- a/docs/classclutchlog_1_1fmt.html +++ b/docs/classclutchlog_1_1fmt.html @@ -28,7 +28,7 @@ @@ -154,7 +154,7 @@ $(document).ready(function(){initNavTree('classclutchlog_1_1fmt.html',''); initR
All styles may not be supported by a given terminal/operating system.
-

Definition at line 366 of file clutchlog.h.

+

Definition at line 376 of file clutchlog.h.

Static Protected Attributes

operator= (

Get the logger instance.

-
+ -

Definition at line 296 of file clutchlog.h.

+

Definition at line 306 of file clutchlog.h.

@@ -403,9 +403,9 @@ void 
operator= (Style will be chosen based on the hash value of the filename among the candidate ones.

See the {filehash_fmt} template tag.

-

Definition at line 1028 of file clutchlog.h.

+

Definition at line 1038 of file clutchlog.h.

-

References _filehash_fmts.

+

References _filehash_fmts.

@@ -437,9 +437,9 @@ void 
operator= (Style will be chosen based on the hash value of the filename among the candidate ones.

See the {funchash_fmt} template tag.

-

Definition at line 1036 of file clutchlog.h.

+

Definition at line 1046 of file clutchlog.h.

-

References _funchash_fmts.

+

References _funchash_fmts.

@@ -471,7 +471,7 @@ void 
operator= (The given list should be ordered, styles will be applied for the corresponding depth level. If the actual depth is larger than the number of styles, the last one is used.

See the {depth_fmt} template tag.

-

Definition at line 1045 of file clutchlog.h.

+

Definition at line 1055 of file clutchlog.h.

@@ -502,11 +502,11 @@ void 
operator= (Return the log level tag corresponding to the given pre-configured name.

Note
This is case sensitive, see the pre-configured _level_word.
-

Definition at line 1060 of file clutchlog.h.

+

Definition at line 1070 of file clutchlog.h.

-

References _word_level.

+

References _word_level.

-

Referenced by threshold().

+

Referenced by threshold().

@@ -549,11 +549,11 @@ template<class ... FMT>

Set the style (color and typo) of the given log level.

This version accept style arguments as if they were passed to clutchlog::fmt.

-

Definition at line 1094 of file clutchlog.h.

+

Definition at line 1104 of file clutchlog.h.

-

References style().

+

References style().

-

Referenced by style().

+

Referenced by style().

@@ -598,12 +598,12 @@ template<class ... FMT>

Replace mark by tag in form.

-
log.replace("{greet} {world}", "\\{greet\\}", "hello");
+
log.replace("{greet} {world}", "\\{greet\\}", "hello");
// returns "hello {world}"
-

Definition at line 1183 of file clutchlog.h.

+

Definition at line 1193 of file clutchlog.h.

-

Referenced by dump(), format(), and replace().

+

Referenced by dump(), format(), and replace().

@@ -612,8 +612,8 @@ template<class ... FMT> -
void log(const level &stage, const std::string &what, const std::string &file, const std::string &func, size_t line) const
Print a log message IF the location matches the given one.
Definition: clutchlog.h:1356
-
static clutchlog & logger()
Get the logger instance.
Definition: clutchlog.h:296
+
static clutchlog & logger()
Get the logger instance.
Definition: clutchlog.h:306
+
void log(const level &stage, const std::string &what, const std::string &file, const std::string &func, const size_t line, const size_t depth_delta=0) const
Print a log message IF the location matches the given one.
Definition: clutchlog.h:1374
clutchlog -  0.14 +  0.15
clutchlog -  0.14 +  0.15
@@ -415,9 +415,9 @@ std::ostream &  diff --git a/docs/clutchlog_8h.html b/docs/clutchlog_8h.html index afb9e50..2dbb3b1 100644 --- a/docs/clutchlog_8h.html +++ b/docs/clutchlog_8h.html @@ -28,7 +28,7 @@ @@ -114,8 +114,7 @@ $(document).ready(function(){initNavTree('clutchlog_8h.html',''); initResizable(

Go to the source code of this file.

@@ -179,8 +178,12 @@ Macros #define  - - + + + + + diff --git a/docs/clutchlog_8h.js b/docs/clutchlog_8h.js index 05cb530..bf6872c 100644 --- a/docs/clutchlog_8h.js +++ b/docs/clutchlog_8h.js @@ -7,6 +7,7 @@ var clutchlog_8h = [ "WITH_CLUTCHLOG", "clutchlog_8h.html#a5c126962abcc7a40e504a6fc3abdfcc4", null ], [ "CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG", "group___default_config.html#ga8564be479b948ee3052b61783c66d415", null ], [ "CLUTCHLOC", "group___use_macros.html#gae8911119d726a43b77f5781cb5a72813", null ], + [ "CLUTCHLOGD", "group___use_macros.html#ga369d365b7c25ec270596c3ca6839cf2c", null ], [ "CLUTCHLOG", "group___use_macros.html#ga6f86187e2b35e7e1907d688f504a197d", null ], [ "CLUTCHDUMP", "group___use_macros.html#ga572e3aa19d8b39e3ed0b9e91961104c2", null ], [ "CLUTCHFUNC", "group___use_macros.html#ga9f77cee4f853e582262930c9c17f90ae", null ], diff --git a/docs/clutchlog_8h__dep__incl.map b/docs/clutchlog_8h__dep__incl.map index 20f2720..4740dc4 100644 --- a/docs/clutchlog_8h__dep__incl.map +++ b/docs/clutchlog_8h__dep__incl.map @@ -1,14 +1,15 @@ - + - - - - - + + + + + + diff --git a/docs/clutchlog_8h__dep__incl.md5 b/docs/clutchlog_8h__dep__incl.md5 index d28cb8a..440c2e6 100644 --- a/docs/clutchlog_8h__dep__incl.md5 +++ b/docs/clutchlog_8h__dep__incl.md5 @@ -1 +1 @@ -f0599479963670ec59fcd0540b0432ef \ No newline at end of file +03a5adb412c477109d73f308278ec653 \ No newline at end of file diff --git a/docs/clutchlog_8h__dep__incl.svg b/docs/clutchlog_8h__dep__incl.svg index 9fe6b9c..1422fbd 100644 --- a/docs/clutchlog_8h__dep__incl.svg +++ b/docs/clutchlog_8h__dep__incl.svg @@ -46,7 +46,7 @@ if (edges && edges.length) { @@ -54,13 +54,13 @@ var sectionId = 'dynsection-1'; clutchlog.h - + Node1 - -clutchlog.h + +clutchlog.h @@ -76,8 +76,8 @@ var sectionId = 'dynsection-1'; Node1->Node2 - - + + @@ -91,8 +91,8 @@ var sectionId = 'dynsection-1'; Node1->Node3 - - + + @@ -106,8 +106,8 @@ var sectionId = 'dynsection-1'; Node1->Node4 - - + + @@ -121,8 +121,8 @@ var sectionId = 'dynsection-1'; Node1->Node5 - - + + @@ -136,8 +136,8 @@ var sectionId = 'dynsection-1'; Node1->Node6 - - + + @@ -151,83 +151,98 @@ var sectionId = 'dynsection-1'; Node1->Node7 - - + + Node8 - - -t-dump.cpp + + +t-depth-delta.cpp Node1->Node8 - - + + Node9 - - -t-fmt-constructors.cpp + + +t-dump.cpp Node1->Node9 - - + + Node10 - - -t-hash-color.cpp + + +t-fmt-constructors.cpp Node1->Node10 - - + + Node11 - - -t-log.cpp + + +t-hash-color.cpp Node1->Node11 - - + + Node12 - - -t-one-line-if.cpp + + +t-log.cpp Node1->Node12 - - + + + + + +Node13 + + +t-one-line-if.cpp + + + + + +Node1->Node13 + + diff --git a/docs/clutchlog_8h__dep__incl_org.svg b/docs/clutchlog_8h__dep__incl_org.svg index df19fdd..3682d73 100644 --- a/docs/clutchlog_8h__dep__incl_org.svg +++ b/docs/clutchlog_8h__dep__incl_org.svg @@ -4,17 +4,17 @@ - + clutchlog.h - + Node1 - -clutchlog.h + +clutchlog.h @@ -30,8 +30,8 @@ Node1->Node2 - - + + @@ -45,8 +45,8 @@ Node1->Node3 - - + + @@ -60,8 +60,8 @@ Node1->Node4 - - + + @@ -75,8 +75,8 @@ Node1->Node5 - - + + @@ -90,8 +90,8 @@ Node1->Node6 - - + + @@ -105,83 +105,98 @@ Node1->Node7 - - + + Node8 - - -t-dump.cpp + + +t-depth-delta.cpp Node1->Node8 - - + + Node9 - - -t-fmt-constructors.cpp + + +t-dump.cpp Node1->Node9 - - + + Node10 - - -t-hash-color.cpp + + +t-fmt-constructors.cpp Node1->Node10 - - + + Node11 - - -t-log.cpp + + +t-hash-color.cpp Node1->Node11 - - + + Node12 - - -t-one-line-if.cpp + + +t-log.cpp Node1->Node12 - - + + + + + +Node13 + + +t-one-line-if.cpp + + + + + +Node1->Node13 + + diff --git a/docs/clutchlog_8h_source.html b/docs/clutchlog_8h_source.html index fa6a0cb..71543c2 100644 --- a/docs/clutchlog_8h_source.html +++ b/docs/clutchlog_8h_source.html @@ -28,7 +28,7 @@ Logo @@ -151,1352 +151,1369 @@ $(document).ready(function(){initNavTree('clutchlog_8h_source.html',''); initRes
76 #define CLUTCHLOC __FILE__, __FUNCTION__, __LINE__
78 
80 #ifndef NDEBUG
-
81  #define CLUTCHLOG( LEVEL, WHAT ) do { \
-
82  auto& clutchlog__logger = clutchlog::logger(); \
-
83  std::ostringstream clutchlog__msg ; clutchlog__msg << WHAT; \
-
84  clutchlog__logger.log(clutchlog::level::LEVEL, clutchlog__msg.str(), CLUTCHLOC); \
+
81  #define CLUTCHLOGD( LEVEL, WHAT, DEPTH_DELTA ) do { \
+
82  auto& clutchlog__logger = clutchlog::logger(); \
+
83  std::ostringstream clutchlog__msg ; clutchlog__msg << WHAT; \
+
84  clutchlog__logger.log(clutchlog::level::LEVEL, clutchlog__msg.str(), CLUTCHLOC, DEPTH_DELTA); \
85  } while(0)
86 #else // not Debug build.
-
87  #define CLUTCHLOG( LEVEL, WHAT ) do { \
-
88  if(clutchlog::level::LEVEL <= CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG) { \
-
89  auto& clutchlog__logger = clutchlog::logger(); \
-
90  std::ostringstream clutchlog__msg ; clutchlog__msg << WHAT; \
-
91  clutchlog__logger.log(clutchlog::level::LEVEL, clutchlog__msg.str(), CLUTCHLOC); \
-
92  } \
+
87  #define CLUTCHLOGD( LEVEL, WHAT, DEPTH_DELTA ) do { \
+
88  if(clutchlog::level::LEVEL <= CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG) { \
+
89  auto& clutchlog__logger = clutchlog::logger(); \
+
90  std::ostringstream clutchlog__msg ; clutchlog__msg << WHAT; \
+
91  clutchlog__logger.log(clutchlog::level::LEVEL, clutchlog__msg.str(), CLUTCHLOC, DEPTH_DELTA); \
+
92  } \
93  } while(0)
94 #endif // NDEBUG
95 
97 #ifndef NDEBUG
-
98  #define CLUTCHDUMP( LEVEL, CONTAINER, FILENAME ) do { \
-
99  auto& clutchlog__logger = clutchlog::logger(); \
-
100  clutchlog__logger.dump(clutchlog::level::LEVEL, std::begin(CONTAINER), std::end(CONTAINER), \
-
101  CLUTCHLOC, FILENAME, CLUTCHDUMP_DEFAULT_SEP); \
-
102  } while(0)
-
103 #else // not Debug build.
-
104  #define CLUTCHDUMP( LEVEL, CONTAINER, FILENAME ) do { \
-
105  if(clutchlog::level::LEVEL <= CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG) { \
-
106  auto& clutchlog__logger = clutchlog::logger(); \
-
107  clutchlog__logger.dump(clutchlog::level::LEVEL, std::begin(CONTAINER), std::end(CONTAINER), \
-
108  CLUTCHLOC, FILENAME, CLUTCHDUMP_DEFAULT_SEP); \
-
109  } \
-
110  } while(0)
-
111 #endif // NDEBUG
-
112 
-
114 #ifndef NDEBUG
-
115  #define CLUTCHFUNC( LEVEL, FUNC, ... ) do { \
-
116  auto& clutchlog__logger = clutchlog::logger(); \
-
117  clutchlog::scope_t clutchlog__scope = clutchlog__logger.locate(clutchlog::level::LEVEL, CLUTCHLOC); \
-
118  if(clutchlog__scope.matches) { \
-
119  FUNC(__VA_ARGS__); \
-
120  } \
-
121  } while(0)
-
122 #else // not Debug build.
-
123  #define CLUTCHFUNC( LEVEL, FUNC, ... ) do { \
-
124  if(clutchlog::level::LEVEL <= CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG) { \
-
125  auto& clutchlog__logger = clutchlog::logger(); \
-
126  clutchlog::scope_t clutchlog__scope = clutchlog__logger.locate(clutchlog::level::LEVEL, CLUTCHLOC); \
-
127  if(clutchlog__scope.matches) { \
-
128  FUNC(__VA_ARGS__); \
-
129  } \
-
130  } \
-
131  } while(0)
-
132 #endif // NDEBUG
-
133 
-
135 #ifndef NDEBUG
-
136  #define CLUTCHCODE( LEVEL, ... ) do { \
-
137  auto& clutchlog__logger = clutchlog::logger(); \
-
138  clutchlog::scope_t clutchlog__scope = clutchlog__logger.locate(clutchlog::level::LEVEL, CLUTCHLOC); \
-
139  if(clutchlog__scope.matches) { \
-
140  __VA_ARGS__ \
-
141  } \
-
142  } while(0)
-
143 #else // not Debug build.
-
144  #define CLUTCHCODE( LEVEL, CODE ) do { \
-
145  if(clutchlog::level::LEVEL <= CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG) { \
-
146  auto& clutchlog__logger = clutchlog::logger(); \
-
147  clutchlog::scope_t clutchlog__scope = clutchlog__logger.locate(clutchlog::level::LEVEL, CLUTCHLOC); \
-
148  if(clutchlog__scope.matches) { \
-
149  CODE \
-
150  } \
-
151  } \
-
152  } while(0)
-
153 #endif // NDEBUG
-
154 
-
157 #else // not WITH_CLUTCHLOG
-
158  // Disabled macros can still be called in Release builds.
-
159  #define CLUTCHLOG( LEVEL, WHAT ) do {/*nothing*/} while(0)
-
160  #define CLUTCHDUMP( LEVEL, CONTAINER, FILENAME ) do {/*nothing*/} while(0)
-
161  #define CLUTCHFUNC( LEVEL, FUNC, ... ) do {/*nothing*/} while(0)
-
162  #define CLUTCHCODE( LEVEL, CODE ) do {/*nothing*/} while(0)
-
163 #endif // WITH_CLUTCHLOG
-
164 
-
165 /**********************************************************************
-
166  * Implementation
-
167  **********************************************************************/
-
168 
-
169 #ifdef WITH_CLUTCHLOG
-
170 
-
177 class clutchlog
-
178 {
-
179  protected:
+
98  #define CLUTCHLOG( LEVEL, WHAT ) \
+
99  CLUTCHLOGD(LEVEL, WHAT, 0)
+
100 #else // not Debug build.
+
101  #define CLUTCHLOG( LEVEL, WHAT ) \
+
102  CLUTCHLOGD(LEVEL, WHAT, 0)
+
103 #endif // NDEBUG
+
104 
+
106 #ifndef NDEBUG
+
107  #define CLUTCHDUMP( LEVEL, CONTAINER, FILENAME ) do { \
+
108  auto& clutchlog__logger = clutchlog::logger(); \
+
109  clutchlog__logger.dump(clutchlog::level::LEVEL, std::begin(CONTAINER), std::end(CONTAINER), \
+
110  CLUTCHLOC, FILENAME, CLUTCHDUMP_DEFAULT_SEP); \
+
111  } while(0)
+
112 #else // not Debug build.
+
113  #define CLUTCHDUMP( LEVEL, CONTAINER, FILENAME ) do { \
+
114  if(clutchlog::level::LEVEL <= CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG) { \
+
115  auto& clutchlog__logger = clutchlog::logger(); \
+
116  clutchlog__logger.dump(clutchlog::level::LEVEL, std::begin(CONTAINER), std::end(CONTAINER), \
+
117  CLUTCHLOC, FILENAME, CLUTCHDUMP_DEFAULT_SEP); \
+
118  } \
+
119  } while(0)
+
120 #endif // NDEBUG
+
121 
+
123 #ifndef NDEBUG
+
124  #define CLUTCHFUNC( LEVEL, FUNC, ... ) do { \
+
125  auto& clutchlog__logger = clutchlog::logger(); \
+
126  clutchlog::scope_t clutchlog__scope = clutchlog__logger.locate(clutchlog::level::LEVEL, CLUTCHLOC); \
+
127  if(clutchlog__scope.matches) { \
+
128  FUNC(__VA_ARGS__); \
+
129  } \
+
130  } while(0)
+
131 #else // not Debug build.
+
132  #define CLUTCHFUNC( LEVEL, FUNC, ... ) do { \
+
133  if(clutchlog::level::LEVEL <= CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG) { \
+
134  auto& clutchlog__logger = clutchlog::logger(); \
+
135  clutchlog::scope_t clutchlog__scope = clutchlog__logger.locate(clutchlog::level::LEVEL, CLUTCHLOC); \
+
136  if(clutchlog__scope.matches) { \
+
137  FUNC(__VA_ARGS__); \
+
138  } \
+
139  } \
+
140  } while(0)
+
141 #endif // NDEBUG
+
142 
+
144 #ifndef NDEBUG
+
145  #define CLUTCHCODE( LEVEL, ... ) do { \
+
146  auto& clutchlog__logger = clutchlog::logger(); \
+
147  clutchlog::scope_t clutchlog__scope = clutchlog__logger.locate(clutchlog::level::LEVEL, CLUTCHLOC); \
+
148  if(clutchlog__scope.matches) { \
+
149  __VA_ARGS__ \
+
150  } \
+
151  } while(0)
+
152 #else // not Debug build.
+
153  #define CLUTCHCODE( LEVEL, CODE ) do { \
+
154  if(clutchlog::level::LEVEL <= CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG) { \
+
155  auto& clutchlog__logger = clutchlog::logger(); \
+
156  clutchlog::scope_t clutchlog__scope = clutchlog__logger.locate(clutchlog::level::LEVEL, CLUTCHLOC); \
+
157  if(clutchlog__scope.matches) { \
+
158  CODE \
+
159  } \
+
160  } \
+
161  } while(0)
+
162 #endif // NDEBUG
+
163 
+
166 #else // not WITH_CLUTCHLOG
+
167  // Disabled macros can still be called in Release builds.
+
168  #define CLUTCHLOG( LEVEL, WHAT ) do {/*nothing*/} while(0)
+
169  #define CLUTCHLOGD( LEVEL, WHAT, DEPTH_DELTA ) do {/*nothing*/} while(0)
+
170  #define CLUTCHDUMP( LEVEL, CONTAINER, FILENAME ) do {/*nothing*/} while(0)
+
171  #define CLUTCHFUNC( LEVEL, FUNC, ... ) do {/*nothing*/} while(0)
+
172  #define CLUTCHCODE( LEVEL, CODE ) do {/*nothing*/} while(0)
+
173 #endif // WITH_CLUTCHLOG
+
174 
+
175 /**********************************************************************
+
176  * Implementation
+
177  **********************************************************************/
+
178 
+
179 #ifdef WITH_CLUTCHLOG
180 
-
185  #ifndef NDEBUG
-
186  #ifndef CLUTCHLOG_DEFAULT_FORMAT
-
187  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1 // Enables: name, depth and depth_marks
-
189  #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1 // Enables: hfill
-
190  #define CLUTCHLOG_DEFAULT_FORMAT "[{name}] {level_letter}:{depth_marks} {msg} {hfill} {func} @ {file}:{line}\n"
-
191  #else
-
192  #define CLUTCHLOG_DEFAULT_FORMAT "[{name}] {level_letter}:{depth_marks} {msg}\t\t\t\t\t{func} @ {file}:{line}\n"
-
193  #endif
-
194  #else
-
195  #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
-
196  #define CLUTCHLOG_DEFAULT_FORMAT "{level_letter} {msg} {hfill} {func} @ {file}:{line}\n"
-
197  #else
-
198  #define CLUTCHLOG_DEFAULT_FORMAT "{level_letter} {msg}\t\t\t\t\t{func} @ {file}:{line}\n"
-
199  #endif
-
200  #endif
-
201  #endif
-
202  #else
-
203  #ifndef CLUTCHLOG_DEFAULT_FORMAT
-
204  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
206  #define CLUTCHLOG_DEFAULT_FORMAT "[{name}] {level_letter}:{depth_marks} {msg} {hfill} {func}\n"
-
207  #else
-
208  #define CLUTCHLOG_DEFAULT_FORMAT "{level_letter} {msg}\t\t\t\t\t{func}\n"
-
209  #endif
-
210  #endif
-
211  #endif
-
212  static inline std::string default_format = CLUTCHLOG_DEFAULT_FORMAT;
-
214 
-
215  #ifndef NDEBUG
-
216  #ifndef CLUTCHDUMP_DEFAULT_FORMAT
-
217  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
219  #define CLUTCHDUMP_DEFAULT_FORMAT "# [{name}] {level} in {func} (at depth {depth}) @ {file}:{line}"
-
220  #else
-
221  #define CLUTCHDUMP_DEFAULT_FORMAT "# {level} in {func} @ {file}:{line}"
-
222  #endif
-
223  #endif // CLUTCHDUMP_DEFAULT_FORMAT
-
224  #else
-
225  #ifndef CLUTCHDUMP_DEFAULT_FORMAT
-
226  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
228  #define CLUTCHDUMP_DEFAULT_FORMAT "# [{name}] {level} in {func} (at depth {depth})"
-
229  #else
-
230  #define CLUTCHDUMP_DEFAULT_FORMAT "# {level} in {func}"
-
231  #endif
-
232  #endif // CLUTCHDUMP_DEFAULT_FORMAT
-
233  #endif
-
234  static inline std::string dump_default_format = CLUTCHDUMP_DEFAULT_FORMAT;
-
236 
-
237  #ifndef CLUTCHDUMP_DEFAULT_SEP
-
238  #define CLUTCHDUMP_DEFAULT_SEP "\n"
-
240  #endif // CLUTCHDUMP_DEFAULT_SEP
-
241  static inline std::string dump_default_sep = CLUTCHDUMP_DEFAULT_SEP;
-
243 
-
244  #ifndef CLUTCHLOG_DEFAULT_DEPTH_MARK
-
245  #define CLUTCHLOG_DEFAULT_DEPTH_MARK ">"
-
247  #endif // CLUTCHLOG_DEFAULT_DEPTH_MARK
-
248  static inline std::string default_depth_mark = CLUTCHLOG_DEFAULT_DEPTH_MARK;
-
250 
-
251  #ifndef CLUTCHLOG_STRIP_CALLS
-
252  #define CLUTCHLOG_STRIP_CALLS 5
-
254  #endif // CLUTCHLOG_STRIP_CALLS
-
255  static inline unsigned int default_strip_calls = CLUTCHLOG_STRIP_CALLS;
-
257 
-
258  #ifndef CLUTCHLOG_DEFAULT_HFILL_MARK
-
259  #define CLUTCHLOG_DEFAULT_HFILL_MARK '.'
-
261  #endif // CLUTCHLOG_DEFAULT_HFILL_MARK
-
262  static inline char default_hfill_char = CLUTCHLOG_DEFAULT_HFILL_MARK;
-
264 
-
265 
-
266  #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
-
267  #ifndef CLUTCHLOG_DEFAULT_HFILL_MAX
-
268  #define CLUTCHLOG_DEFAULT_HFILL_MAX 300
-
269  #endif
-
270  #ifndef CLUTCHLOG_DEFAULT_HFILL_MIN
-
271  #define CLUTCHLOG_DEFAULT_HFILL_MIN 150
-
272  #endif
-
273  #endif
-
274  static inline size_t default_hfill_max = CLUTCHLOG_DEFAULT_HFILL_MAX;
-
277  static inline size_t default_hfill_min = CLUTCHLOG_DEFAULT_HFILL_MIN;
-
278 
-
279  // NOTE: there is no CLUTCHLOG_HFILL_STYLE for defaulting,
-
280  // but you can still set `hfill_style(...)` on the logger singleton.
-
281  /* @} DefaultConfig */
-
282  /* @} */
-
283 
-
284 
-
285  public:
-
286 
-
296  static clutchlog& logger()
-
297  {
-
298  static clutchlog instance;
-
299  return instance;
-
300  }
-
301 
-
303  enum level {critical=0, error=1, warning=2, progress=3, note=4, info=5, debug=6, xdebug=7};
-
304 
-
366  class fmt {
-
367  public:
-
369  enum class ansi {
-
371  colors_16 = -1, // Not supposed to be casted.
-
373  colors_256 = 5, // Casted as short in color::operator<<.
-
375  colors_16M = 2 // Casted as short in color::operator<<
-
376  } mode;
-
377 
-
379  enum class typo {
-
380  reset = 0,
-
381  bold = 1,
-
382  underline = 4,
-
383  inverse = 7,
-
384  none = -1
-
385  } style;
-
386 
-
389  enum class fg {
-
391  black = 30,
-
392  red = 31,
-
393  green = 32,
-
394  yellow = 33,
-
395  blue = 34,
-
396  magenta = 35,
-
397  cyan = 36,
-
398  white = 37,
-
399  bright_black = 90,
-
400  bright_red = 91,
-
401  bright_green = 92,
-
402  bright_yellow = 93,
-
403  bright_blue = 94,
-
404  bright_magenta = 95,
-
405  bright_cyan = 96,
-
406  bright_white = 97,
-
407  none = -1
-
408  } fore;
-
409 
-
411  enum class bg {
-
412  black = 40,
-
413  red = 41,
-
414  green = 42,
-
415  yellow = 43,
-
416  blue = 44,
-
417  magenta = 45,
-
418  cyan = 46,
-
419  white = 47,
-
420  bright_black = 100,
-
421  bright_red = 101,
-
422  bright_green = 102,
-
423  bright_yellow = 103,
-
424  bright_blue = 104,
-
425  bright_magenta = 105,
-
426  bright_cyan = 106,
-
427  bright_white = 107,
-
428  none = -1
-
429  } back;
-
430 
-
431  protected:
-
433  friend std::ostream& operator<<(std::ostream& os, const std::tuple<fg,bg,typo>& fbs)
-
434  {
-
435  auto [f,b,s] = fbs;
-
436  std::vector<short> codes; codes.reserve(3);
-
437  if(f != fg::none) { codes.push_back(static_cast<short>(f));}
-
438  if(b != bg::none) { codes.push_back(static_cast<short>(b));}
-
439  if(s != typo::none) { codes.push_back(static_cast<short>(s));}
-
440  if(codes.size() == 0) {
-
441  return os;
-
442 
-
443  } else {
-
444  os << "\033[";
-
445  os << codes[0];
-
446  for(size_t i=1; i < codes.size(); ++i) {
-
447  os << ";" << codes[i];
-
448  }
-
449  os << "m";
-
450  }
-
451  return os;
-
452  }
-
453 
-
455  friend std::ostream& operator<<(std::ostream& os, const typo& s)
-
456  {
-
457  if(s != typo::none) {
-
458  os << "\033[" << static_cast<short>(s) << "m";
-
459  }
-
460  return os;
-
461  }
-
462 
-
465  protected:
-
470  struct color {
-
471  ansi mode; // Not const to allow for the implicit copy assignemnt operator.
+
187 class clutchlog
+
188 {
+
189  protected:
+
190 
+
195  #ifndef NDEBUG
+
196  #ifndef CLUTCHLOG_DEFAULT_FORMAT
+
197  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1 // Enables: name, depth and depth_marks
+
199  #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1 // Enables: hfill
+
200  #define CLUTCHLOG_DEFAULT_FORMAT "[{name}] {level_letter}:{depth_marks} {msg} {hfill} {func} @ {file}:{line}\n"
+
201  #else
+
202  #define CLUTCHLOG_DEFAULT_FORMAT "[{name}] {level_letter}:{depth_marks} {msg}\t\t\t\t\t{func} @ {file}:{line}\n"
+
203  #endif
+
204  #else
+
205  #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
+
206  #define CLUTCHLOG_DEFAULT_FORMAT "{level_letter} {msg} {hfill} {func} @ {file}:{line}\n"
+
207  #else
+
208  #define CLUTCHLOG_DEFAULT_FORMAT "{level_letter} {msg}\t\t\t\t\t{func} @ {file}:{line}\n"
+
209  #endif
+
210  #endif
+
211  #endif
+
212  #else
+
213  #ifndef CLUTCHLOG_DEFAULT_FORMAT
+
214  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
216  #define CLUTCHLOG_DEFAULT_FORMAT "[{name}] {level_letter}:{depth_marks} {msg} {hfill} {func}\n"
+
217  #else
+
218  #define CLUTCHLOG_DEFAULT_FORMAT "{level_letter} {msg}\t\t\t\t\t{func}\n"
+
219  #endif
+
220  #endif
+
221  #endif
+
222  static inline std::string default_format = CLUTCHLOG_DEFAULT_FORMAT;
+
224 
+
225  #ifndef NDEBUG
+
226  #ifndef CLUTCHDUMP_DEFAULT_FORMAT
+
227  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
229  #define CLUTCHDUMP_DEFAULT_FORMAT "# [{name}] {level} in {func} (at depth {depth}) @ {file}:{line}"
+
230  #else
+
231  #define CLUTCHDUMP_DEFAULT_FORMAT "# {level} in {func} @ {file}:{line}"
+
232  #endif
+
233  #endif // CLUTCHDUMP_DEFAULT_FORMAT
+
234  #else
+
235  #ifndef CLUTCHDUMP_DEFAULT_FORMAT
+
236  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
238  #define CLUTCHDUMP_DEFAULT_FORMAT "# [{name}] {level} in {func} (at depth {depth})"
+
239  #else
+
240  #define CLUTCHDUMP_DEFAULT_FORMAT "# {level} in {func}"
+
241  #endif
+
242  #endif // CLUTCHDUMP_DEFAULT_FORMAT
+
243  #endif
+
244  static inline std::string dump_default_format = CLUTCHDUMP_DEFAULT_FORMAT;
+
246 
+
247  #ifndef CLUTCHDUMP_DEFAULT_SEP
+
248  #define CLUTCHDUMP_DEFAULT_SEP "\n"
+
250  #endif // CLUTCHDUMP_DEFAULT_SEP
+
251  static inline std::string dump_default_sep = CLUTCHDUMP_DEFAULT_SEP;
+
253 
+
254  #ifndef CLUTCHLOG_DEFAULT_DEPTH_MARK
+
255  #define CLUTCHLOG_DEFAULT_DEPTH_MARK ">"
+
257  #endif // CLUTCHLOG_DEFAULT_DEPTH_MARK
+
258  static inline std::string default_depth_mark = CLUTCHLOG_DEFAULT_DEPTH_MARK;
+
260 
+
261  #ifndef CLUTCHLOG_STRIP_CALLS
+
262  #define CLUTCHLOG_STRIP_CALLS 5
+
264  #endif // CLUTCHLOG_STRIP_CALLS
+
265  static inline unsigned int default_strip_calls = CLUTCHLOG_STRIP_CALLS;
+
267 
+
268  #ifndef CLUTCHLOG_DEFAULT_HFILL_MARK
+
269  #define CLUTCHLOG_DEFAULT_HFILL_MARK '.'
+
271  #endif // CLUTCHLOG_DEFAULT_HFILL_MARK
+
272  static inline char default_hfill_char = CLUTCHLOG_DEFAULT_HFILL_MARK;
+
274 
+
275 
+
276  #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
+
277  #ifndef CLUTCHLOG_DEFAULT_HFILL_MAX
+
278  #define CLUTCHLOG_DEFAULT_HFILL_MAX 300
+
279  #endif
+
280  #ifndef CLUTCHLOG_DEFAULT_HFILL_MIN
+
281  #define CLUTCHLOG_DEFAULT_HFILL_MIN 150
+
282  #endif
+
283  #endif
+
284  static inline size_t default_hfill_max = CLUTCHLOG_DEFAULT_HFILL_MAX;
+
287  static inline size_t default_hfill_min = CLUTCHLOG_DEFAULT_HFILL_MIN;
+
288 
+
289  // NOTE: there is no CLUTCHLOG_HFILL_STYLE for defaulting,
+
290  // but you can still set `hfill_style(...)` on the logger singleton.
+
291  /* @} DefaultConfig */
+
292  /* @} */
+
293 
+
294 
+
295  public:
+
296 
+
306  static clutchlog& logger()
+
307  {
+
308  static clutchlog instance;
+
309  return instance;
+
310  }
+
311 
+
313  enum level {critical=0, error=1, warning=2, progress=3, note=4, info=5, debug=6, xdebug=7};
+
314 
+
376  class fmt {
+
377  public:
+
379  enum class ansi {
+
381  colors_16 = -1, // Not supposed to be casted.
+
383  colors_256 = 5, // Casted as short in color::operator<<.
+
385  colors_16M = 2 // Casted as short in color::operator<<
+
386  } mode;
+
387 
+
389  enum class typo {
+
390  reset = 0,
+
391  bold = 1,
+
392  underline = 4,
+
393  inverse = 7,
+
394  none = -1
+
395  } style;
+
396 
+
399  enum class fg {
+
401  black = 30,
+
402  red = 31,
+
403  green = 32,
+
404  yellow = 33,
+
405  blue = 34,
+
406  magenta = 35,
+
407  cyan = 36,
+
408  white = 37,
+
409  bright_black = 90,
+
410  bright_red = 91,
+
411  bright_green = 92,
+
412  bright_yellow = 93,
+
413  bright_blue = 94,
+
414  bright_magenta = 95,
+
415  bright_cyan = 96,
+
416  bright_white = 97,
+
417  none = -1
+
418  } fore;
+
419 
+
421  enum class bg {
+
422  black = 40,
+
423  red = 41,
+
424  green = 42,
+
425  yellow = 43,
+
426  blue = 44,
+
427  magenta = 45,
+
428  cyan = 46,
+
429  white = 47,
+
430  bright_black = 100,
+
431  bright_red = 101,
+
432  bright_green = 102,
+
433  bright_yellow = 103,
+
434  bright_blue = 104,
+
435  bright_magenta = 105,
+
436  bright_cyan = 106,
+
437  bright_white = 107,
+
438  none = -1
+
439  } back;
+
440 
+
441  protected:
+
443  friend std::ostream& operator<<(std::ostream& os, const std::tuple<fg,bg,typo>& fbs)
+
444  {
+
445  auto [f,b,s] = fbs;
+
446  std::vector<short> codes; codes.reserve(3);
+
447  if(f != fg::none) { codes.push_back(static_cast<short>(f));}
+
448  if(b != bg::none) { codes.push_back(static_cast<short>(b));}
+
449  if(s != typo::none) { codes.push_back(static_cast<short>(s));}
+
450  if(codes.size() == 0) {
+
451  return os;
+
452 
+
453  } else {
+
454  os << "\033[";
+
455  os << codes[0];
+
456  for(size_t i=1; i < codes.size(); ++i) {
+
457  os << ";" << codes[i];
+
458  }
+
459  os << "m";
+
460  }
+
461  return os;
+
462  }
+
463 
+
465  friend std::ostream& operator<<(std::ostream& os, const typo& s)
+
466  {
+
467  if(s != typo::none) {
+
468  os << "\033[" << static_cast<short>(s) << "m";
+
469  }
+
470  return os;
+
471  }
472 
-
474  enum class ground { // idem.
-
475  fore = 38,
-
476  back = 48
-
477  } type;
-
478 
-
484  color(ansi a, ground g) : mode(a), type(g) {}
-
485 
-
487  virtual bool is_set() const = 0;
+
475  protected:
+
480  struct color {
+
481  ansi mode; // Not const to allow for the implicit copy assignemnt operator.
+
482 
+
484  enum class ground { // idem.
+
485  fore = 38,
+
486  back = 48
+
487  } type;
488 
-
490  virtual std::ostream& print_on( std::ostream& os) const = 0;
-
491 
-
493  friend std::ostream& operator<<(std::ostream& os, const color& c)
-
494  {
-
495  if(c.is_set()) {
-
496  os << "\033[" << static_cast<short>(c.type) << ";" << static_cast<short>(c.mode) << ";";
-
497  c.print_on(os);
-
498  os << "m";
-
499  }
-
500  return os;
-
501  }
-
502  };
-
503 
-
504  // There is no color_16 because it would be the same as color_256, only with different indices,
-
505  // hence making it more complicated for the user to select the right constructor.
-
506  // Here, we just use enum for 16 colors, and indices for 256 colors.
-
507 
-
509  struct color_256 : public color {
-
513  short index;
-
514 
-
518  color_256(ground t) : color(ansi::colors_256, t), index(-1) {}
-
519 
-
525  color_256(ground t, const short i) : color(ansi::colors_256, t), index(i) {assert(-1 <= i and i <= 255);}
-
526 
-
528  bool is_set() const {return index > -1;}
+
494  color(ansi a, ground g) : mode(a), type(g) {}
+
495 
+
497  virtual bool is_set() const = 0;
+
498 
+
500  virtual std::ostream& print_on( std::ostream& os) const = 0;
+
501 
+
503  friend std::ostream& operator<<(std::ostream& os, const color& c)
+
504  {
+
505  if(c.is_set()) {
+
506  os << "\033[" << static_cast<short>(c.type) << ";" << static_cast<short>(c.mode) << ";";
+
507  c.print_on(os);
+
508  os << "m";
+
509  }
+
510  return os;
+
511  }
+
512  };
+
513 
+
514  // There is no color_16 because it would be the same as color_256, only with different indices,
+
515  // hence making it more complicated for the user to select the right constructor.
+
516  // Here, we just use enum for 16 colors, and indices for 256 colors.
+
517 
+
519  struct color_256 : public color {
+
523  short index;
+
524 
+
528  color_256(ground t) : color(ansi::colors_256, t), index(-1) {}
529 
-
531  std::ostream& print_on( std::ostream& os) const
-
532  {
-
533  os << index;
-
534  return os;
-
535  }
-
536  };
-
537 
-
539  struct fg_256 : public color_256 {
-
541  fg_256() : color_256(ground::fore) {}
-
542 
-
546  fg_256(const short f) : color_256(ground::fore, f) {}
+
535  color_256(ground t, const short i) : color(ansi::colors_256, t), index(i) {assert(-1 <= i and i <= 255);}
+
536 
+
538  bool is_set() const {return index > -1;}
+
539 
+
541  std::ostream& print_on( std::ostream& os) const
+
542  {
+
543  os << index;
+
544  return os;
+
545  }
+
546  };
547 
-
551  fg_256(const fg&) : color_256(ground::fore, -1) {}
+
549  struct fg_256 : public color_256 {
+
551  fg_256() : color_256(ground::fore) {}
552 
-
553  } fore_256;
-
554 
-
556  struct bg_256 : public color_256 {
-
558  bg_256() : color_256(ground::back) {}
-
559 
-
563  bg_256(const short b) : color_256(ground::back, b) {}
+
556  fg_256(const short f) : color_256(ground::fore, f) {}
+
557 
+
561  fg_256(const fg&) : color_256(ground::fore, -1) {}
+
562 
+
563  } fore_256;
564 
-
568  bg_256(const bg&) : color_256(ground::back, -1) {}
+
566  struct bg_256 : public color_256 {
+
568  bg_256() : color_256(ground::back) {}
569 
-
570  } back_256;
-
571 
-
573  struct color_16M : public color {
-
577  short red, green, blue;
-
578 
-
582  color_16M(ground t) : color(ansi::colors_16M, t), red(-1), green(-1), blue(-1) {}
-
583 
-
591  color_16M(ground t, short r, short g, short b)
-
592  : color(ansi::colors_16M, t), red(r), green(g), blue(b) {}
+
573  bg_256(const short b) : color_256(ground::back, b) {}
+
574 
+
578  bg_256(const bg&) : color_256(ground::back, -1) {}
+
579 
+
580  } back_256;
+
581 
+
583  struct color_16M : public color {
+
587  short red, green, blue;
+
588 
+
592  color_16M(ground t) : color(ansi::colors_16M, t), red(-1), green(-1), blue(-1) {}
593 
-
601  color_16M(ground t, const std::string& srgb) : color(ansi::colors_16M, t)
-
602  {
-
603  assert(srgb.size() == 7);
-
604  if(srgb.size() != 7) {
-
605  red = -1;
-
606  green = -1;
-
607  blue = -1;
-
608  } else {
-
609  char i = 0;
-
610  if(srgb.at(0) == '#') {
-
611  i = 1;
-
612  }
-
613  std::istringstream(srgb.substr(0+i,2)) >> std::hex >> red;
-
614  std::istringstream(srgb.substr(2+i,2)) >> std::hex >> green;
-
615  std::istringstream(srgb.substr(4+i,2)) >> std::hex >> blue;
-
616  }
-
617  assert(-1 <= red and red <= 255);
-
618  assert(-1 <= green and green <= 255);
-
619  assert(-1 <= blue and blue <= 255);
-
620  }
-
621 
-
623  bool is_set() const {return red > -1 and green > -1 and blue > -1;}
-
624 
-
626  std::ostream& print_on( std::ostream& os) const
-
627  {
-
628  os << red << ";" << green << ";" << blue;
-
629  return os;
+
601  color_16M(ground t, short r, short g, short b)
+
602  : color(ansi::colors_16M, t), red(r), green(g), blue(b) {}
+
603 
+
611  color_16M(ground t, const std::string& srgb) : color(ansi::colors_16M, t)
+
612  {
+
613  assert(srgb.size() == 7);
+
614  if(srgb.size() != 7) {
+
615  red = -1;
+
616  green = -1;
+
617  blue = -1;
+
618  } else {
+
619  char i = 0;
+
620  if(srgb.at(0) == '#') {
+
621  i = 1;
+
622  }
+
623  std::istringstream(srgb.substr(0+i,2)) >> std::hex >> red;
+
624  std::istringstream(srgb.substr(2+i,2)) >> std::hex >> green;
+
625  std::istringstream(srgb.substr(4+i,2)) >> std::hex >> blue;
+
626  }
+
627  assert(-1 <= red and red <= 255);
+
628  assert(-1 <= green and green <= 255);
+
629  assert(-1 <= blue and blue <= 255);
630  }
-
631  };
-
632 
-
634  struct fg_16M : public color_16M {
-
636  fg_16M() : color_16M(ground::fore) {}
-
637 
-
646  fg_16M(short r, short g, short b) : color_16M(ground::fore, r,g,b) {}
+
631 
+
633  bool is_set() const {return red > -1 and green > -1 and blue > -1;}
+
634 
+
636  std::ostream& print_on( std::ostream& os) const
+
637  {
+
638  os << red << ";" << green << ";" << blue;
+
639  return os;
+
640  }
+
641  };
+
642 
+
644  struct fg_16M : public color_16M {
+
646  fg_16M() : color_16M(ground::fore) {}
647 
-
654  fg_16M(const std::string& srgb) : color_16M(ground::fore, srgb) {}
-
655 
-
659  fg_16M(const fg&) : color_16M(ground::fore, -1,-1,-1) {}
-
660 
-
661  } fore_16M;
-
662 
-
664  struct bg_16M : public color_16M {
-
666  bg_16M() : color_16M(ground::back) {}
-
667 
-
676  bg_16M(short r, short g, short b) : color_16M(ground::back, r,g,b) {}
+
656  fg_16M(short r, short g, short b) : color_16M(ground::fore, r,g,b) {}
+
657 
+
664  fg_16M(const std::string& srgb) : color_16M(ground::fore, srgb) {}
+
665 
+
669  fg_16M(const fg&) : color_16M(ground::fore, -1,-1,-1) {}
+
670 
+
671  } fore_16M;
+
672 
+
674  struct bg_16M : public color_16M {
+
676  bg_16M() : color_16M(ground::back) {}
677 
-
684  bg_16M(const std::string& srgb) : color_16M(ground::back, srgb) {}
-
685 
-
689  bg_16M(const bg&) : color_16M(ground::back, -1,-1,-1) {}
-
690 
-
691  } back_16M;
-
692 
-
695  public:
-
697  fmt() : mode(ansi::colors_16), style(typo::none), fore(fg::none), back(bg::none) {}
-
698 
-
701  fmt( fg f, bg b = bg::none, typo s = typo::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
702  fmt( fg f, typo s , bg b = bg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
703  fmt( bg b, fg f = fg::none, typo s = typo::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
704  fmt( bg b, typo s , fg f = fg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
705  fmt(typo s, fg f = fg::none, bg b = bg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
706  fmt(typo s, bg b , fg f = fg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
711  fmt(fg_256 f, bg_256 b, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(f), back_256(b) {}
-
712  fmt(fg_256 f, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(f), back_256(bg::none) {}
-
713  fmt(fg, bg_256 b, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(fg::none), back_256(b) {}
-
718  fmt(const short fr, const short fg, const short fb,
-
719  const short gr, const short gg, const short gb,
-
720  typo s = typo::none)
-
721  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(gr,gg,gb) {}
-
722  fmt(fg,
-
723  const short gr, const short gg, const short gb,
-
724  typo s = typo::none)
-
725  : mode(ansi::colors_16M), style(s), fore_16M(fg::none), back_16M(gr,gg,gb) {}
-
726  fmt(const short fr, const short fg, const short fb,
-
727  bg, typo s = typo::none)
-
728  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(bg::none) {}
-
729  fmt(const short fr, const short fg, const short fb,
+
686  bg_16M(short r, short g, short b) : color_16M(ground::back, r,g,b) {}
+
687 
+
694  bg_16M(const std::string& srgb) : color_16M(ground::back, srgb) {}
+
695 
+
699  bg_16M(const bg&) : color_16M(ground::back, -1,-1,-1) {}
+
700 
+
701  } back_16M;
+
702 
+
705  public:
+
707  fmt() : mode(ansi::colors_16), style(typo::none), fore(fg::none), back(bg::none) {}
+
708 
+
711  fmt( fg f, bg b = bg::none, typo s = typo::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
712  fmt( fg f, typo s , bg b = bg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
713  fmt( bg b, fg f = fg::none, typo s = typo::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
714  fmt( bg b, typo s , fg f = fg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
715  fmt(typo s, fg f = fg::none, bg b = bg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
716  fmt(typo s, bg b , fg f = fg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
721  fmt(fg_256 f, bg_256 b, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(f), back_256(b) {}
+
722  fmt(fg_256 f, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(f), back_256(bg::none) {}
+
723  fmt(fg, bg_256 b, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(fg::none), back_256(b) {}
+
728  fmt(const short fr, const short fg, const short fb,
+
729  const short gr, const short gg, const short gb,
730  typo s = typo::none)
-
731  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(bg::none) {}
-
732 
-
733  fmt(const std::string& f, const std::string& b, typo s = typo::none)
-
734  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(b) {}
-
735  fmt(fg, const std::string& b, typo s = typo::none)
-
736  : mode(ansi::colors_16M), style(s), fore_16M(fg::none), back_16M(b) {}
-
737  fmt(const std::string& f, bg, typo s = typo::none)
-
738  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(bg::none) {}
-
739  fmt(const std::string& f, typo s = typo::none)
-
740  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(bg::none) {}
-
743  protected:
-
744 
-
746  std::ostream& print_on( std::ostream& os) const
-
747  {
-
748  if(mode == ansi::colors_16) {
-
749  // Print all in a single escape.
-
750  os << std::make_tuple(fore,back,style);
-
751 
-
752  } else {
-
753  // 256 or 16M: always print separated escapes for foreground/background.
-
754  if(mode == ansi::colors_256) {
-
755  os << fore_256;
-
756  os << back_256;
-
757 
-
758  } else if(mode == ansi::colors_16M) {
-
759  os << fore_16M;
-
760  os << back_16M;
-
761  }
-
762  // In any case, print the style separately.
-
763  os << style;
-
764  }
-
765  return os;
-
766  }
+
731  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(gr,gg,gb) {}
+
732  fmt(fg,
+
733  const short gr, const short gg, const short gb,
+
734  typo s = typo::none)
+
735  : mode(ansi::colors_16M), style(s), fore_16M(fg::none), back_16M(gr,gg,gb) {}
+
736  fmt(const short fr, const short fg, const short fb,
+
737  bg, typo s = typo::none)
+
738  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(bg::none) {}
+
739  fmt(const short fr, const short fg, const short fb,
+
740  typo s = typo::none)
+
741  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(bg::none) {}
+
742 
+
743  fmt(const std::string& f, const std::string& b, typo s = typo::none)
+
744  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(b) {}
+
745  fmt(fg, const std::string& b, typo s = typo::none)
+
746  : mode(ansi::colors_16M), style(s), fore_16M(fg::none), back_16M(b) {}
+
747  fmt(const std::string& f, bg, typo s = typo::none)
+
748  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(bg::none) {}
+
749  fmt(const std::string& f, typo s = typo::none)
+
750  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(bg::none) {}
+
753  protected:
+
754 
+
756  std::ostream& print_on( std::ostream& os) const
+
757  {
+
758  if(mode == ansi::colors_16) {
+
759  // Print all in a single escape.
+
760  os << std::make_tuple(fore,back,style);
+
761 
+
762  } else {
+
763  // 256 or 16M: always print separated escapes for foreground/background.
+
764  if(mode == ansi::colors_256) {
+
765  os << fore_256;
+
766  os << back_256;
767 
-
768  public:
-
780  friend std::ostream& operator<<(std::ostream& os, const fmt& fmt)
-
781  {
-
782  return fmt.print_on(os);
-
783  }
-
784 
-
795  std::string operator()( const std::string& msg ) const
-
796  {
-
797  std::ostringstream os;
-
798  this->print_on(os);
-
799  fmt reset(fmt::typo::reset);
-
800  os << msg;
-
801  reset.print_on(os);
-
802  return os.str();
-
803  }
-
804 
-
807  std::string str() const
-
808  {
-
809  std::ostringstream os;
-
810  this->print_on(os);
-
811  return os.str();
-
812  }
-
813 
-
814  static fmt hash( const std::string& str, const std::vector<fmt> domain = {})
-
815  {
-
816  size_t h = std::hash<std::string>{}(str);
-
817  if(domain.size() == 0) {
-
818  return fmt(static_cast<short>(h % 256));
-
819  } else {
-
820  return fmt(domain[h % domain.size()]);
-
821  }
+
768  } else if(mode == ansi::colors_16M) {
+
769  os << fore_16M;
+
770  os << back_16M;
+
771  }
+
772  // In any case, print the style separately.
+
773  os << style;
+
774  }
+
775  return os;
+
776  }
+
777 
+
778  public:
+
790  friend std::ostream& operator<<(std::ostream& os, const fmt& fmt)
+
791  {
+
792  return fmt.print_on(os);
+
793  }
+
794 
+
805  std::string operator()( const std::string& msg ) const
+
806  {
+
807  std::ostringstream os;
+
808  this->print_on(os);
+
809  fmt reset(fmt::typo::reset);
+
810  os << msg;
+
811  reset.print_on(os);
+
812  return os.str();
+
813  }
+
814 
+
817  std::string str() const
+
818  {
+
819  std::ostringstream os;
+
820  this->print_on(os);
+
821  return os.str();
822  }
-
823  }; // fmt class
-
824 
-
830  public:
-
831  clutchlog(clutchlog const&) = delete;
-
832  void operator=(clutchlog const&) = delete;
-
833 
-
834  private:
-
835  clutchlog() :
-
836  // system, main, log
-
837  _strip_calls(clutchlog::default_strip_calls),
-
838  _level_word({
-
839  {level::critical,"Critical"},
-
840  {level::error ,"Error"},
-
841  {level::warning ,"Warning"},
-
842  {level::progress,"Progress"},
-
843  {level::note ,"Note"},
-
844  {level::info ,"Info"},
-
845  {level::debug ,"Debug"},
-
846  {level::xdebug ,"XDebug"}
-
847  }),
-
848  _level_short({
-
849  {level::critical, "Crit"},
-
850  {level::error , "Erro"},
-
851  {level::warning , "Warn"},
-
852  {level::progress, "Prog"},
-
853  {level::note , "Note"},
-
854  {level::info , "Info"},
-
855  {level::debug , "Dbug"},
-
856  {level::xdebug , "XDbg"}
+
823 
+
824  static fmt hash( const std::string& str, const std::vector<fmt> domain = {})
+
825  {
+
826  size_t h = std::hash<std::string>{}(str);
+
827  if(domain.size() == 0) {
+
828  return fmt(static_cast<short>(h % 256));
+
829  } else {
+
830  return fmt(domain[h % domain.size()]);
+
831  }
+
832  }
+
833  }; // fmt class
+
834 
+
840  public:
+
841  clutchlog(clutchlog const&) = delete;
+
842  void operator=(clutchlog const&) = delete;
+
843 
+
844  private:
+
845  clutchlog() :
+
846  // system, main, log
+
847  _strip_calls(clutchlog::default_strip_calls),
+
848  _level_word({
+
849  {level::critical,"Critical"},
+
850  {level::error ,"Error"},
+
851  {level::warning ,"Warning"},
+
852  {level::progress,"Progress"},
+
853  {level::note ,"Note"},
+
854  {level::info ,"Info"},
+
855  {level::debug ,"Debug"},
+
856  {level::xdebug ,"XDebug"}
857  }),
-
858  _level_fmt({
-
859  {level::critical,fmt(fmt::fg::red, fmt::typo::underline)},
-
860  {level::error ,fmt(fmt::fg::red, fmt::typo::bold)},
-
861  {level::warning ,fmt(fmt::fg::magenta, fmt::typo::bold)},
-
862  {level::progress,fmt()},
-
863  {level::note ,fmt()},
-
864  {level::info ,fmt()},
-
865  {level::debug ,fmt()},
-
866  {level::xdebug ,fmt()}
+
858  _level_short({
+
859  {level::critical, "Crit"},
+
860  {level::error , "Erro"},
+
861  {level::warning , "Warn"},
+
862  {level::progress, "Prog"},
+
863  {level::note , "Note"},
+
864  {level::info , "Info"},
+
865  {level::debug , "Dbug"},
+
866  {level::xdebug , "XDbg"}
867  }),
-
868  _format_log(clutchlog::default_format),
-
869  _format_dump(clutchlog::dump_default_format),
-
870  #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
-
871  _hfill_char(clutchlog::default_hfill_char),
-
872  _hfill_fmt(fmt::fg::none),
-
873  _hfill_max(clutchlog::default_hfill_max),
-
874  _hfill_min(clutchlog::default_hfill_min),
-
875  #endif
-
876  _out(&std::clog),
-
877  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
878  _depth(std::numeric_limits<size_t>::max() - _strip_calls),
-
879  _depth_mark(clutchlog::default_depth_mark),
-
880  #endif
-
881  _stage(level::error),
-
882  _in_file(".*"),
-
883  _in_func(".*"),
-
884  _in_line(".*")
-
885  // Empty vectors by default:
-
886  // _filehash_fmts
-
887  // _funchash_fmts
-
888  // _depth_fmts
-
889  {
-
890  // Reverse the level->word map into a word->level map.
-
891  for(auto& lw : _level_word) {
-
892  _word_level[lw.second] = lw.first;
-
893  }
-
894 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
-
895  struct winsize w;
-
896  ioctl(STDERR_FILENO, TIOCGWINSZ, &w);
-
897  _nb_columns = std::max(std::min((size_t)w.ws_col, default_hfill_max), default_hfill_min);
-
898 #endif
-
899  }
-
900 
-
901  protected:
-
903  size_t _strip_calls;
-
905  const std::map<level,std::string> _level_word;
-
907  std::map<std::string,level> _word_level;
-
909  std::map<level,std::string> _level_short;
-
911  std::map<level,fmt> _level_fmt;
-
913  std::string _format_log;
-
915  std::string _format_dump;
-
916  #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
-
917 
-
918  char _hfill_char;
-
920  fmt _hfill_fmt;
-
922  size_t _hfill_max;
-
924  size_t _hfill_min;
-
925  #endif
-
926 
-
927  std::ostream* _out;
-
928  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
929 
-
930  size_t _depth;
-
932  std::string _depth_mark;
-
933  #endif
-
934 
-
935  level _stage;
-
937  std::regex _in_file;
-
939  std::regex _in_func;
-
941  std::regex _in_line;
-
942 
-
944  std::vector<fmt> _filehash_fmts;
-
946  std::vector<fmt> _funchash_fmts;
-
947 
-
948 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
949 
-
950  static const size_t _max_buffer = 4096;
-
952  std::vector<fmt> _depth_fmts;
-
953 #endif
-
954 
-
955 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
-
956 
-
957  size_t _nb_columns;
-
958 #endif
+
868  _level_fmt({
+
869  {level::critical,fmt(fmt::fg::red, fmt::typo::underline)},
+
870  {level::error ,fmt(fmt::fg::red, fmt::typo::bold)},
+
871  {level::warning ,fmt(fmt::fg::magenta, fmt::typo::bold)},
+
872  {level::progress,fmt()},
+
873  {level::note ,fmt()},
+
874  {level::info ,fmt()},
+
875  {level::debug ,fmt()},
+
876  {level::xdebug ,fmt()}
+
877  }),
+
878  _format_log(clutchlog::default_format),
+
879  _format_dump(clutchlog::dump_default_format),
+
880  #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
+
881  _hfill_char(clutchlog::default_hfill_char),
+
882  _hfill_fmt(fmt::fg::none),
+
883  _hfill_max(clutchlog::default_hfill_max),
+
884  _hfill_min(clutchlog::default_hfill_min),
+
885  #endif
+
886  _out(&std::clog),
+
887  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
888  _depth(std::numeric_limits<size_t>::max() - _strip_calls),
+
889  _depth_mark(clutchlog::default_depth_mark),
+
890  #endif
+
891  _stage(level::error),
+
892  _in_file(".*"),
+
893  _in_func(".*"),
+
894  _in_line(".*")
+
895  // Empty vectors by default:
+
896  // _filehash_fmts
+
897  // _funchash_fmts
+
898  // _depth_fmts
+
899  {
+
900  // Reverse the level->word map into a word->level map.
+
901  for(auto& lw : _level_word) {
+
902  _word_level[lw.second] = lw.first;
+
903  }
+
904 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
+
905  struct winsize w;
+
906  ioctl(STDERR_FILENO, TIOCGWINSZ, &w);
+
907  _nb_columns = std::max(std::min((size_t)w.ws_col, default_hfill_max), default_hfill_min);
+
908 #endif
+
909  }
+
910 
+
911  protected:
+
913  size_t _strip_calls;
+
915  const std::map<level,std::string> _level_word;
+
917  std::map<std::string,level> _word_level;
+
919  std::map<level,std::string> _level_short;
+
921  std::map<level,fmt> _level_fmt;
+
923  std::string _format_log;
+
925  std::string _format_dump;
+
926  #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
+
927 
+
928  char _hfill_char;
+
930  fmt _hfill_fmt;
+
932  size_t _hfill_max;
+
934  size_t _hfill_min;
+
935  #endif
+
936 
+
937  std::ostream* _out;
+
938  #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
939 
+
940  size_t _depth;
+
942  std::string _depth_mark;
+
943  #endif
+
944 
+
945  level _stage;
+
947  std::regex _in_file;
+
949  std::regex _in_func;
+
951  std::regex _in_line;
+
952 
+
954  std::vector<fmt> _filehash_fmts;
+
956  std::vector<fmt> _funchash_fmts;
+
957 
+
958 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
959 
-
961  public:
-
962 
-
966  void format(const std::string& format) {_format_log = format;}
-
969  std::string format() const {return _format_log;}
-
970 
-
972  void format_comment(const std::string& format) {_format_dump = format;}
-
974  std::string format_comment() const {return _format_dump;}
-
975 
-
977  void out(std::ostream& out) {_out = &out;}
-
979  std::ostream& out() {return *_out;}
+
960  static const size_t _max_buffer = 4096;
+
962  std::vector<fmt> _depth_fmts;
+
963 #endif
+
964 
+
965 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
+
966 
+
967  size_t _nb_columns;
+
968 #endif
+
969 
+
971  public:
+
972 
+
976  void format(const std::string& format) {_format_log = format;}
+
979  std::string format() const {return _format_log;}
980 
-
981 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
982  void depth(size_t d) {_depth = d;}
-
985  size_t depth() const {return _depth;}
-
986 
-
988  void depth_mark(const std::string mark) {_depth_mark = mark;}
-
990  std::string depth_mark() const {return _depth_mark;}
-
991 
-
993  void strip_calls(const size_t n) {_strip_calls = n;}
-
995  size_t strip_calls() const {return _strip_calls;}
-
996 #endif
-
997 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
-
998  void hfill_mark(const char mark) {_hfill_char = mark;}
-
1001  char hfill_mark() const {return _hfill_char;}
-
1003  void hfill_style(fmt style) {_hfill_fmt = style;}
-
1008  template<class ... FMT>
-
1009  void hfill_style(FMT... styles) { this->hfill_style(fmt(styles...)); }
-
1011  fmt hfill_style() const {return _hfill_fmt;}
-
1013  void hfill_max(const size_t nmax) {_hfill_max = nmax;}
-
1015  size_t hfill_max() {return _hfill_max;}
-
1017  void hfill_min(const size_t nmin) {_hfill_min = nmin;}
-
1019  size_t hfill_min() {return _hfill_min;}
-
1020 #endif
-
1021 
-
1028  void filehash_styles(std::vector<fmt> styles) {_filehash_fmts = styles;}
-
1036  void funchash_styles(std::vector<fmt> styles) {_funchash_fmts = styles;}
-
1045  void depth_styles(std::vector<fmt> styles) {_depth_fmts = styles;}
-
1046 
-
1048  void threshold(level l) {_stage = l;}
-
1050  void threshold(const std::string& l) {_stage = this->level_of(l);}
-
1052  level threshold() const {return _stage;}
-
1054  const std::map<std::string,level>& levels() const { return _word_level;}
-
1055 
-
1060  level level_of(const std::string name)
-
1061  {
-
1062  const auto ilevel = _word_level.find(name);
-
1063  if( ilevel != std::end(_word_level)) {
-
1064  return ilevel->second;
-
1065  } else {
-
1066  throw std::out_of_range("'" + name + "' is not a valid log level name");
-
1067  }
-
1068  }
-
1069 
-
1071  void file(std::string file) {_in_file = file;}
-
1073  void func(std::string func) {_in_func = func;}
-
1075  void line(std::string line) {_in_line = line;}
-
1076 
-
1078  void location(
-
1079  const std::string& in_file,
-
1080  const std::string& in_function=".*",
-
1081  const std::string& in_line=".*"
-
1082  )
-
1083  {
-
1084  file(in_file);
-
1085  func(in_function);
-
1086  line(in_line);
-
1087  }
-
1088 
-
1093  template<class ... FMT>
-
1094  void style(level stage, FMT... styles) { this->style(stage,fmt(styles...)); }
-
1096  void style(level stage, fmt style) { _level_fmt.at(stage) = style; }
-
1098  fmt style(level stage) const { return _level_fmt.at(stage); }
-
1099 
-
1102  public:
-
1103 
-
1107  struct scope_t {
-
1110  bool matches;
-
1112  level stage;
-
1113 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
1114 
-
1115  size_t depth;
-
1116 #endif
-
1117 
-
1118  bool there;
-
1120  scope_t() :
-
1121  matches(false),
-
1122  stage(level::xdebug),
-
1123 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
1124  depth(0),
-
1125 #endif
-
1126  there(false)
-
1127  {}
-
1128  }; // scope_t
-
1129 
-
1130 
-
1132  scope_t locate(
-
1133  const level& stage,
-
1134  const std::string& file,
-
1135  const std::string& func,
-
1136  const size_t line
-
1137  ) const
-
1138  {
-
1139  scope_t scope; // False scope by default.
+
982  void format_comment(const std::string& format) {_format_dump = format;}
+
984  std::string format_comment() const {return _format_dump;}
+
985 
+
987  void out(std::ostream& out) {_out = &out;}
+
989  std::ostream& out() {return *_out;}
+
990 
+
991 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
992  void depth(size_t d) {_depth = d;}
+
995  size_t depth() const {return _depth;}
+
996 
+
998  void depth_mark(const std::string mark) {_depth_mark = mark;}
+
1000  std::string depth_mark() const {return _depth_mark;}
+
1001 
+
1003  void strip_calls(const size_t n) {_strip_calls = n;}
+
1005  size_t strip_calls() const {return _strip_calls;}
+
1006 #endif
+
1007 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
+
1008  void hfill_mark(const char mark) {_hfill_char = mark;}
+
1011  char hfill_mark() const {return _hfill_char;}
+
1013  void hfill_style(fmt style) {_hfill_fmt = style;}
+
1018  template<class ... FMT>
+
1019  void hfill_style(FMT... styles) { this->hfill_style(fmt(styles...)); }
+
1021  fmt hfill_style() const {return _hfill_fmt;}
+
1023  void hfill_max(const size_t nmax) {_hfill_max = nmax;}
+
1025  size_t hfill_max() {return _hfill_max;}
+
1027  void hfill_min(const size_t nmin) {_hfill_min = nmin;}
+
1029  size_t hfill_min() {return _hfill_min;}
+
1030 #endif
+
1031 
+
1038  void filehash_styles(std::vector<fmt> styles) {_filehash_fmts = styles;}
+
1046  void funchash_styles(std::vector<fmt> styles) {_funchash_fmts = styles;}
+
1055  void depth_styles(std::vector<fmt> styles) {_depth_fmts = styles;}
+
1056 
+
1058  void threshold(level l) {_stage = l;}
+
1060  void threshold(const std::string& l) {_stage = this->level_of(l);}
+
1062  level threshold() const {return _stage;}
+
1064  const std::map<std::string,level>& levels() const { return _word_level;}
+
1065 
+
1070  level level_of(const std::string name)
+
1071  {
+
1072  const auto ilevel = _word_level.find(name);
+
1073  if( ilevel != std::end(_word_level)) {
+
1074  return ilevel->second;
+
1075  } else {
+
1076  throw std::out_of_range("'" + name + "' is not a valid log level name");
+
1077  }
+
1078  }
+
1079 
+
1081  void file(std::string file) {_in_file = file;}
+
1083  void func(std::string func) {_in_func = func;}
+
1085  void line(std::string line) {_in_line = line;}
+
1086 
+
1088  void location(
+
1089  const std::string& in_file,
+
1090  const std::string& in_function=".*",
+
1091  const std::string& in_line=".*"
+
1092  )
+
1093  {
+
1094  file(in_file);
+
1095  func(in_function);
+
1096  line(in_line);
+
1097  }
+
1098 
+
1103  template<class ... FMT>
+
1104  void style(level stage, FMT... styles) { this->style(stage,fmt(styles...)); }
+
1106  void style(level stage, fmt style) { _level_fmt.at(stage) = style; }
+
1108  fmt style(level stage) const { return _level_fmt.at(stage); }
+
1109 
+
1112  public:
+
1113 
+
1117  struct scope_t {
+
1120  bool matches;
+
1122  level stage;
+
1123 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1124 
+
1125  size_t depth;
+
1126 #endif
+
1127 
+
1128  bool there;
+
1130  scope_t() :
+
1131  matches(false),
+
1132  stage(level::xdebug),
+
1133 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1134  depth(0),
+
1135 #endif
+
1136  there(false)
+
1137  {}
+
1138  }; // scope_t
+
1139 
1140 
-
1141  /***** Log level stage *****/
-
1142  // Test stage first, because it's fastest.
-
1143  scope.stage = stage;
-
1144  if(not (scope.stage <= _stage)) {
-
1145  // Bypass useless computations if no match
-
1146  // because of the stage.
-
1147  return scope;
-
1148  }
-
1149 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
1150  /***** Stack depth *****/
-
1151  // Backtrace in second, quite fast.
-
1152  size_t stack_depth;
-
1153  void *buffer[_max_buffer];
-
1154  stack_depth = backtrace(buffer, _max_buffer);
-
1155  scope.depth = stack_depth;
-
1156  if(not (scope.depth <= _depth + _strip_calls)) {
-
1157  // Bypass if no match.
-
1158  return scope;
-
1159  }
-
1160 #endif
-
1161 
-
1162  /***** Location *****/
-
1163  // Location last, slowest.
-
1164  std::ostringstream sline; sline << line;
-
1165  scope.there =
-
1166  std::regex_search(file, _in_file)
-
1167  and std::regex_search(func, _in_func)
-
1168  and std::regex_search(sline.str(), _in_line);
-
1169 
-
1170  // No need to retest stage and depth, which are true here.
-
1171  scope.matches = scope.there;
-
1172 
-
1173  return scope;
-
1174  } // locate
-
1175 
-
1183  std::string replace(
-
1184  const std::string& form,
-
1185  const std::string& mark,
-
1186  const std::string& tag
-
1187  ) const
-
1188  {
-
1189  // Useless debug code, unless something fancy would be done with name tags.
-
1190  // std::regex re;
-
1191  // try {
-
1192  // re = std::regex(mark);
-
1193  //
-
1194  // } catch(const std::regex_error& e) {
-
1195  // std::cerr << "ERROR with a regular expression \"" << mark << "\": ";
-
1196  // switch(e.code()) {
-
1197  // case std::regex_constants::error_collate:
-
1198  // std::cerr << "the expression contains an invalid collating element name";
-
1199  // break;
-
1200  // case std::regex_constants::error_ctype:
-
1201  // std::cerr << "the expression contains an invalid character class name";
-
1202  // break;
-
1203  // case std::regex_constants::error_escape:
-
1204  // std::cerr << "the expression contains an invalid escaped character or a trailing escape";
-
1205  // break;
-
1206  // case std::regex_constants::error_backref:
-
1207  // std::cerr << "the expression contains an invalid back reference";
-
1208  // break;
-
1209  // case std::regex_constants::error_brack:
-
1210  // std::cerr << "the expression contains mismatched square brackets ('[' and ']')";
-
1211  // break;
-
1212  // case std::regex_constants::error_paren:
-
1213  // std::cerr << "the expression contains mismatched parentheses ('(' and ')')";
-
1214  // break;
-
1215  // case std::regex_constants::error_brace:
-
1216  // std::cerr << "the expression contains mismatched curly braces ('{' and '}')";
-
1217  // break;
-
1218  // case std::regex_constants::error_badbrace:
-
1219  // std::cerr << "the expression contains an invalid range in a {} expression";
-
1220  // break;
-
1221  // case std::regex_constants::error_range:
-
1222  // std::cerr << "the expression contains an invalid character range (e.g. [b-a])";
-
1223  // break;
-
1224  // case std::regex_constants::error_space:
-
1225  // std::cerr << "there was not enough memory to convert the expression into a finite state machine";
-
1226  // break;
-
1227  // case std::regex_constants::error_badrepeat:
-
1228  // std::cerr << "one of *?+{ was not preceded by a valid regular expression";
-
1229  // break;
-
1230  // case std::regex_constants::error_complexity:
-
1231  // std::cerr << "the complexity of an attempted match exceeded a predefined level";
-
1232  // break;
-
1233  // case std::regex_constants::error_stack:
-
1234  // std::cerr << "there was not enough memory to perform a match";
-
1235  // break;
-
1236  // default:
-
1237  // std::cerr << "unknown error";
-
1238  // }
-
1239  // std::cerr << std::endl;
-
1240  // throw;
-
1241  // } // catch
-
1242 
-
1243  const std::regex re(mark);
-
1244  return std::regex_replace(form, re, tag);
-
1245  }
-
1246 
-
1248  std::string replace(
-
1249  const std::string& form,
-
1250  const std::string& mark,
-
1251  const size_t tag
-
1252  ) const
-
1253  {
-
1254  std::ostringstream stag; stag << tag;
-
1255  return replace(form, mark, stag.str());
-
1256  }
-
1257 
-
1259  std::string format(
-
1260  std::string row,
-
1261  const std::string& what,
-
1262 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
1263  const std::string& name,
-
1264 #endif
-
1265  const level& stage,
-
1266  const std::string& file,
-
1267  const std::string& func,
-
1268  const size_t line
-
1269 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
1270  ,
-
1271  const size_t depth
-
1272 #endif
-
1273  ) const
-
1274  {
-
1275  row = replace(row, "\\{msg\\}", what);
-
1276  row = replace(row, "\\{file\\}", file);
-
1277  row = replace(row, "\\{func\\}", func);
-
1278  row = replace(row, "\\{line\\}", line);
-
1279 
-
1280  row = replace(row, "\\{level\\}", _level_word.at(stage));
-
1281  std::string letter(1, _level_word.at(stage).at(0)); // char -> string
-
1282  row = replace(row, "\\{level_letter\\}", letter);
-
1283 
-
1284  row = replace(row, "\\{level_short\\}", _level_short.at(stage));
-
1285 
-
1286 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
1287  size_t actual_depth = depth - _strip_calls;
-
1288  row = replace(row, "\\{name\\}", name);
-
1289  row = replace(row, "\\{depth\\}", actual_depth);
-
1290 
-
1291  std::ostringstream chevrons;
-
1292  for(size_t i = _strip_calls; i < depth; ++i) {
-
1293  chevrons << _depth_mark;
-
1294  }
-
1295  row = replace(row, "\\{depth_marks\\}", chevrons.str());
-
1296 
-
1297  if(_depth_fmts.size() == 0) {
-
1298  row = replace(row, "\\{depth_fmt\\}", fmt(actual_depth % 256).str() );
-
1299  } else {
-
1300  row = replace(row, "\\{depth_fmt\\}",
-
1301  _depth_fmts[std::min(actual_depth,_depth_fmts.size()-1)].str() );
-
1302  }
-
1303 #endif
-
1304  row = replace(row, "\\{level_fmt\\}", _level_fmt.at(stage).str());
-
1305  row = replace(row, "\\{filehash_fmt\\}", fmt::hash(file, _filehash_fmts).str() );
-
1306  row = replace(row, "\\{funchash_fmt\\}", fmt::hash(func, _funchash_fmts).str() );
-
1307 
-
1308 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
-
1309  // hfill is replaced last to allow for correct line width estimation.
-
1310  const std::string raw_row = replace(row, "\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "");
-
1311  const std::string hfill_tag = "{hfill}";
-
1312  const size_t hfill_pos = row.find(hfill_tag);
-
1313  const size_t raw_hfill_pos = raw_row.find(hfill_tag);
-
1314  const size_t nb_columns = std::max(std::min((size_t)_nb_columns, _hfill_max), _hfill_min);
-
1315  if(hfill_pos != std::string::npos) {
-
1316  assert(raw_hfill_pos != std::string::npos);
-
1317  if(nb_columns > 0) {
-
1318  const size_t left_len = raw_hfill_pos;
-
1319  const size_t right_len = raw_row.size() - raw_hfill_pos - hfill_tag.size();
-
1320  if(right_len+left_len > nb_columns) {
-
1321  // The right part would go over the terminal width: add a new row.
-
1322  if(right_len < nb_columns) {
-
1323  // There is room for the right part on a new line.
-
1324  const std::string hfill(std::max((size_t)0, nb_columns-right_len), _hfill_char);
-
1325  const std::string hfill_styled = _hfill_fmt(hfill);
-
1326  row = replace(row, "\\{hfill\\}", "\n"+hfill_styled);
-
1327  } else {
-
1328  // Right part still goes over columns: let it go.
-
1329  const std::string hfill(1, _hfill_char);
-
1330  const std::string hfill_styled = _hfill_fmt(hfill);
-
1331  row = replace(row, "\\{hfill\\}", "\n"+hfill_styled);
-
1332  }
-
1333  } else {
-
1334  // There is some space in between left and right parts.
-
1335  const std::string hfill(std::max((size_t)0, nb_columns - (right_len+left_len)), _hfill_char);
-
1336  const std::string hfill_styled = _hfill_fmt(hfill);
-
1337  row = replace(row, "\\{hfill\\}", hfill_styled);
-
1338  }
-
1339  } else {
-
1340  // We don't know the terminal width.
-
1341  const std::string hfill(1, _hfill_char);
-
1342  const std::string hfill_styled = _hfill_fmt(hfill);
-
1343  row = replace(row, "\\{hfill\\}", hfill_styled);
-
1344  }
-
1345  }
-
1346 #else
-
1347  // We cannot know the terminal width.
-
1348  const std::string hfill(1, _hfill_char);
-
1349  const std::string hfill_styled = _hfill_fmt(hfill);
-
1350  row = replace(row, "\\{hfill\\}", hfill_styled);
-
1351 #endif
-
1352  return _level_fmt.at(stage)(row);
-
1353  }
-
1354 
-
1356  void log(
-
1357  const level& stage,
-
1358  const std::string& what,
-
1359  const std::string& file, const std::string& func, size_t line
-
1360  ) const
-
1361  {
-
1362  scope_t scope = locate(stage, file, func, line);
-
1363 
-
1364  if(scope.matches) {
-
1365 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
1366  *_out << format(_format_log, what, basename(getenv("_")),
-
1367  stage, file, func,
-
1368  line, scope.depth );
-
1369 #else
-
1370  *_out << format(_format_log, what,
-
1371  stage, file, func,
-
1372  line );
-
1373 
-
1374 #endif
-
1375  _out->flush();
-
1376  } // if scopes.matches
-
1377  }
-
1378 
-
1380  template<class In>
-
1381  void dump(
-
1382  const level& stage,
-
1383  const In container_begin, const In container_end,
-
1384  const std::string& file, const std::string& func, size_t line,
-
1385  const std::string& filename_template = "dump_{n}.dat",
-
1386  const std::string sep = dump_default_sep
-
1387  ) const
-
1388  {
-
1389  scope_t scope = locate(stage, file, func, line);
-
1390 
-
1391  if(scope.matches) {
-
1392  const std::string tag = "\\{n\\}";
-
1393  const std::regex re(tag);
-
1394  std::string outfile = "";
-
1395 
-
1396  // If the file name template has the {n} tag.
-
1397  if(std::regex_search(filename_template, re)) {
-
1398  // Increment n until a free one is found.
-
1399  size_t n = 0;
-
1400  do {
-
1401  outfile = replace(filename_template, tag, n);
-
1402  n++;
-
1403  } while( fs::exists( outfile ) );
-
1404 
-
1405  } else {
-
1406  // Use the parameter as is.
-
1407  outfile = filename_template;
-
1408  }
-
1409 
-
1410  std::ofstream fd(outfile);
-
1411 
-
1412  if(_format_dump.size() > 0) {
-
1413 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
1414  fd << format(_format_dump, "", basename(getenv("_")),
-
1415  stage, file, func,
-
1416  line, scope.depth );
-
1417 #else
-
1418  fd << format(_format_dump, "",
-
1419  stage, file, func,
-
1420  line );
-
1421 #endif
-
1422  fd << sep; // sep after comment line.
-
1423  }
-
1424 
-
1425  std::copy(container_begin, container_end,
-
1426  std::ostream_iterator<typename In::value_type>(fd, sep.c_str()));
+
1142  scope_t locate(
+
1143  const level& stage,
+
1144  const std::string& file,
+
1145  const std::string& func,
+
1146  const size_t line
+
1147  ) const
+
1148  {
+
1149  scope_t scope; // False scope by default.
+
1150 
+
1151  /***** Log level stage *****/
+
1152  // Test stage first, because it's fastest.
+
1153  scope.stage = stage;
+
1154  if(not (scope.stage <= _stage)) {
+
1155  // Bypass useless computations if no match
+
1156  // because of the stage.
+
1157  return scope;
+
1158  }
+
1159 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1160  /***** Stack depth *****/
+
1161  // Backtrace in second, quite fast.
+
1162  size_t stack_depth;
+
1163  void *buffer[_max_buffer];
+
1164  stack_depth = backtrace(buffer, _max_buffer);
+
1165  scope.depth = stack_depth;
+
1166  if(not (scope.depth <= _depth + _strip_calls)) {
+
1167  // Bypass if no match.
+
1168  return scope;
+
1169  }
+
1170 #endif
+
1171 
+
1172  /***** Location *****/
+
1173  // Location last, slowest.
+
1174  std::ostringstream sline; sline << line;
+
1175  scope.there =
+
1176  std::regex_search(file, _in_file)
+
1177  and std::regex_search(func, _in_func)
+
1178  and std::regex_search(sline.str(), _in_line);
+
1179 
+
1180  // No need to retest stage and depth, which are true here.
+
1181  scope.matches = scope.there;
+
1182 
+
1183  return scope;
+
1184  } // locate
+
1185 
+
1193  std::string replace(
+
1194  const std::string& form,
+
1195  const std::string& mark,
+
1196  const std::string& tag
+
1197  ) const
+
1198  {
+
1199  // Useless debug code, unless something fancy would be done with name tags.
+
1200  // std::regex re;
+
1201  // try {
+
1202  // re = std::regex(mark);
+
1203  //
+
1204  // } catch(const std::regex_error& e) {
+
1205  // std::cerr << "ERROR with a regular expression \"" << mark << "\": ";
+
1206  // switch(e.code()) {
+
1207  // case std::regex_constants::error_collate:
+
1208  // std::cerr << "the expression contains an invalid collating element name";
+
1209  // break;
+
1210  // case std::regex_constants::error_ctype:
+
1211  // std::cerr << "the expression contains an invalid character class name";
+
1212  // break;
+
1213  // case std::regex_constants::error_escape:
+
1214  // std::cerr << "the expression contains an invalid escaped character or a trailing escape";
+
1215  // break;
+
1216  // case std::regex_constants::error_backref:
+
1217  // std::cerr << "the expression contains an invalid back reference";
+
1218  // break;
+
1219  // case std::regex_constants::error_brack:
+
1220  // std::cerr << "the expression contains mismatched square brackets ('[' and ']')";
+
1221  // break;
+
1222  // case std::regex_constants::error_paren:
+
1223  // std::cerr << "the expression contains mismatched parentheses ('(' and ')')";
+
1224  // break;
+
1225  // case std::regex_constants::error_brace:
+
1226  // std::cerr << "the expression contains mismatched curly braces ('{' and '}')";
+
1227  // break;
+
1228  // case std::regex_constants::error_badbrace:
+
1229  // std::cerr << "the expression contains an invalid range in a {} expression";
+
1230  // break;
+
1231  // case std::regex_constants::error_range:
+
1232  // std::cerr << "the expression contains an invalid character range (e.g. [b-a])";
+
1233  // break;
+
1234  // case std::regex_constants::error_space:
+
1235  // std::cerr << "there was not enough memory to convert the expression into a finite state machine";
+
1236  // break;
+
1237  // case std::regex_constants::error_badrepeat:
+
1238  // std::cerr << "one of *?+{ was not preceded by a valid regular expression";
+
1239  // break;
+
1240  // case std::regex_constants::error_complexity:
+
1241  // std::cerr << "the complexity of an attempted match exceeded a predefined level";
+
1242  // break;
+
1243  // case std::regex_constants::error_stack:
+
1244  // std::cerr << "there was not enough memory to perform a match";
+
1245  // break;
+
1246  // default:
+
1247  // std::cerr << "unknown error";
+
1248  // }
+
1249  // std::cerr << std::endl;
+
1250  // throw;
+
1251  // } // catch
+
1252 
+
1253  const std::regex re(mark);
+
1254  return std::regex_replace(form, re, tag);
+
1255  }
+
1256 
+
1258  std::string replace(
+
1259  const std::string& form,
+
1260  const std::string& mark,
+
1261  const size_t tag
+
1262  ) const
+
1263  {
+
1264  std::ostringstream stag; stag << tag;
+
1265  return replace(form, mark, stag.str());
+
1266  }
+
1267 
+
1269  std::string format(
+
1270  std::string row,
+
1271  const std::string& what,
+
1272 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1273  const std::string& name,
+
1274 #endif
+
1275  const level& stage,
+
1276  const std::string& file,
+
1277  const std::string& func,
+
1278  const size_t line
+
1279 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1280  ,
+
1281  const size_t depth
+
1282 #endif
+
1283  ) const
+
1284  {
+
1285  row = replace(row, "\\{msg\\}", what);
+
1286  row = replace(row, "\\{file\\}", file);
+
1287  row = replace(row, "\\{func\\}", func);
+
1288  row = replace(row, "\\{line\\}", line);
+
1289 
+
1290  row = replace(row, "\\{level\\}", _level_word.at(stage));
+
1291  std::string letter(1, _level_word.at(stage).at(0)); // char -> string
+
1292  row = replace(row, "\\{level_letter\\}", letter);
+
1293 
+
1294  row = replace(row, "\\{level_short\\}", _level_short.at(stage));
+
1295 
+
1296 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1297  size_t actual_depth = depth - _strip_calls;
+
1298  row = replace(row, "\\{name\\}", name);
+
1299  row = replace(row, "\\{depth\\}", actual_depth);
+
1300 
+
1301  if(_depth_fmts.size() == 0) {
+
1302  row = replace(row, "\\{depth_fmt\\}", fmt(actual_depth % 256).str() );
+
1303 
+
1304  std::ostringstream chevrons;
+
1305  for(size_t i = 0; i < actual_depth; ++i) {
+
1306  chevrons << _depth_mark;
+
1307  }
+
1308  row = replace(row, "\\{depth_marks\\}", chevrons.str());
+
1309 
+
1310  } else {
+
1311  row = replace(row, "\\{depth_fmt\\}",
+
1312  _depth_fmts[std::min(actual_depth,_depth_fmts.size()-1)].str() );
+
1313 
+
1314  std::ostringstream chevrons;
+
1315  for(size_t i = 0; i < actual_depth; ++i) {
+
1316  chevrons << _depth_fmts[std::min(i+1,_depth_fmts.size()-1)].str()
+
1317  << _depth_mark;
+
1318  }
+
1319  row = replace(row, "\\{depth_marks\\}", chevrons.str());
+
1320  }
+
1321 #endif
+
1322  row = replace(row, "\\{level_fmt\\}", _level_fmt.at(stage).str());
+
1323  row = replace(row, "\\{filehash_fmt\\}", fmt::hash(file, _filehash_fmts).str() );
+
1324  row = replace(row, "\\{funchash_fmt\\}", fmt::hash(func, _funchash_fmts).str() );
+
1325 
+
1326 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
+
1327  // hfill is replaced last to allow for correct line width estimation.
+
1328  const std::string raw_row = replace(row, "\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "");
+
1329  const std::string hfill_tag = "{hfill}";
+
1330  const size_t hfill_pos = row.find(hfill_tag);
+
1331  const size_t raw_hfill_pos = raw_row.find(hfill_tag);
+
1332  const size_t nb_columns = std::max(std::min((size_t)_nb_columns, _hfill_max), _hfill_min);
+
1333  if(hfill_pos != std::string::npos) {
+
1334  assert(raw_hfill_pos != std::string::npos);
+
1335  if(nb_columns > 0) {
+
1336  const size_t left_len = raw_hfill_pos;
+
1337  const size_t right_len = raw_row.size() - raw_hfill_pos - hfill_tag.size();
+
1338  if(right_len+left_len > nb_columns) {
+
1339  // The right part would go over the terminal width: add a new row.
+
1340  if(right_len < nb_columns) {
+
1341  // There is room for the right part on a new line.
+
1342  const std::string hfill(std::max((size_t)0, nb_columns-right_len), _hfill_char);
+
1343  const std::string hfill_styled = _hfill_fmt(hfill);
+
1344  row = replace(row, "\\{hfill\\}", "\n"+hfill_styled);
+
1345  } else {
+
1346  // Right part still goes over columns: let it go.
+
1347  const std::string hfill(1, _hfill_char);
+
1348  const std::string hfill_styled = _hfill_fmt(hfill);
+
1349  row = replace(row, "\\{hfill\\}", "\n"+hfill_styled);
+
1350  }
+
1351  } else {
+
1352  // There is some space in between left and right parts.
+
1353  const std::string hfill(std::max((size_t)0, nb_columns - (right_len+left_len)), _hfill_char);
+
1354  const std::string hfill_styled = _hfill_fmt(hfill);
+
1355  row = replace(row, "\\{hfill\\}", hfill_styled);
+
1356  }
+
1357  } else {
+
1358  // We don't know the terminal width.
+
1359  const std::string hfill(1, _hfill_char);
+
1360  const std::string hfill_styled = _hfill_fmt(hfill);
+
1361  row = replace(row, "\\{hfill\\}", hfill_styled);
+
1362  }
+
1363  }
+
1364 #else
+
1365  // We cannot know the terminal width.
+
1366  const std::string hfill(1, _hfill_char);
+
1367  const std::string hfill_styled = _hfill_fmt(hfill);
+
1368  row = replace(row, "\\{hfill\\}", hfill_styled);
+
1369 #endif
+
1370  return _level_fmt.at(stage)(row);
+
1371  }
+
1372 
+
1374  void log(
+
1375  const level& stage,
+
1376  const std::string& what,
+
1377  const std::string& file, const std::string& func, const size_t line,
+
1378  const size_t depth_delta = 0
+
1379  ) const
+
1380  {
+
1381  scope_t scope = locate(stage, file, func, line);
+
1382 
+
1383  if(scope.matches) {
+
1384 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1385  *_out << format(_format_log, what, basename(getenv("_")),
+
1386  stage, file, func,
+
1387  line, scope.depth + depth_delta );
+
1388 #else
+
1389  *_out << format(_format_log, what,
+
1390  stage, file, func,
+
1391  line );
+
1392 #endif
+
1393  _out->flush();
+
1394  } // if scopes.matches
+
1395  }
+
1396 
+
1398  template<class In>
+
1399  void dump(
+
1400  const level& stage,
+
1401  const In container_begin, const In container_end,
+
1402  const std::string& file, const std::string& func, const size_t line,
+
1403  const std::string& filename_template = "dump_{n}.dat",
+
1404  const std::string sep = dump_default_sep
+
1405  ) const
+
1406  {
+
1407  scope_t scope = locate(stage, file, func, line);
+
1408 
+
1409  if(scope.matches) {
+
1410  const std::string tag = "\\{n\\}";
+
1411  const std::regex re(tag);
+
1412  std::string outfile = "";
+
1413 
+
1414  // If the file name template has the {n} tag.
+
1415  if(std::regex_search(filename_template, re)) {
+
1416  // Increment n until a free one is found.
+
1417  size_t n = 0;
+
1418  do {
+
1419  outfile = replace(filename_template, tag, n);
+
1420  n++;
+
1421  } while( fs::exists( outfile ) );
+
1422 
+
1423  } else {
+
1424  // Use the parameter as is.
+
1425  outfile = filename_template;
+
1426  }
1427 
-
1428  fd.close();
-
1429  } // if scopes.matches
-
1430  }
-
1431 
-
1433 };
-
1434 
-
1437 #else // not WITH_CLUTCHLOG
-
1438 
-
1439 
-
1440 /**********************************************************************
-
1441  * Fake implementation
-
1442  **********************************************************************/
-
1443 
-
1444 // Equivalent class with empty methods, will be optimized out
-
1445 // while allowing to actually have calls implemented without WITH_CLUTCHLOG guards.
-
1446 #pragma GCC diagnostic push
-
1447 #pragma GCC diagnostic ignored "-Wreturn-type"
-
1448 class clutchlog
-
1449 {
-
1450  public:
-
1451  static clutchlog& logger() {}
-
1452  enum level {critical=0, error=1, warning=2, progress=3, note=4, info=5, debug=6, xdebug=7};
-
1453  class fmt {
-
1454  public:
-
1455  enum class ansi { colors_16, colors_256, colors_16M} mode;
-
1456  enum class typo { reset, bold, underline, inverse, none} style;
-
1457  enum class fg { black, red, green, yellow, blue, magenta, cyan, white, bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white, none} fore;
-
1458  enum class bg { black, red, green, yellow, blue, magenta, cyan, white, bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white, none } back;
-
1459  protected:
-
1460  friend std::ostream& operator<<(std::ostream&, const std::tuple<fg,bg,typo>&) {}
-
1461  friend std::ostream& operator<<(std::ostream&, const typo&) {}
-
1462  protected:
-
1463  struct color {
-
1464  ansi mode;
-
1465  enum class ground { fore, back } type;
-
1466  color(ansi a, ground g) : mode(a), type(g) {}
-
1467  virtual bool is_set() const = 0;
-
1468  virtual std::ostream& print_on( std::ostream&) const = 0;
-
1469  friend std::ostream& operator<<(std::ostream&, const color&) {}
-
1470  };
-
1471  struct color_256 : public color {
-
1472  short index;
-
1473  color_256(ground t) : color(ansi::colors_256, t), index(-1) {}
-
1474  color_256(ground t, const short i) : color(ansi::colors_256, t), index(i) {}
-
1475  bool is_set() const {}
-
1476  std::ostream& print_on( std::ostream&) const {}
-
1477  };
-
1478  struct fg_256 : public color_256 {
-
1479  fg_256() : color_256(ground::fore) {}
-
1480  fg_256(const short f) : color_256(ground::fore, f) {}
-
1481  fg_256(const fg&) : color_256(ground::fore, -1) {}
-
1482  } fore_256;
-
1483  struct bg_256 : public color_256 {
-
1484  bg_256() : color_256(ground::back) {}
-
1485  bg_256(const short b) : color_256(ground::back, b) {}
-
1486  bg_256(const bg&) : color_256(ground::back, -1) {}
-
1487  } back_256;
-
1488  struct color_16M : public color {
-
1489  short red, green, blue;
-
1490  color_16M(ground t) : color(ansi::colors_16M, t), red(-1), green(-1), blue(-1) {}
-
1491  color_16M(ground t, short r, short g, short b) : color(ansi::colors_16M, t), red(r), green(g), blue(b) {}
-
1492  color_16M(ground t, const std::string&) : color(ansi::colors_16M, t) {}
-
1493  bool is_set() const {return red > -1 and green > -1 and blue > -1;}
-
1494  std::ostream& print_on( std::ostream&) const {}
+
1428  std::ofstream fd(outfile);
+
1429 
+
1430  if(_format_dump.size() > 0) {
+
1431 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1432  fd << format(_format_dump, "", basename(getenv("_")),
+
1433  stage, file, func,
+
1434  line, scope.depth );
+
1435 #else
+
1436  fd << format(_format_dump, "",
+
1437  stage, file, func,
+
1438  line );
+
1439 #endif
+
1440  fd << sep; // sep after comment line.
+
1441  }
+
1442 
+
1443  std::copy(container_begin, container_end,
+
1444  std::ostream_iterator<typename In::value_type>(fd, sep.c_str()));
+
1445 
+
1446  fd.close();
+
1447  } // if scopes.matches
+
1448  }
+
1449 
+
1451 };
+
1452 
+
1455 #else // not WITH_CLUTCHLOG
+
1456 
+
1457 
+
1458 /**********************************************************************
+
1459  * Fake implementation
+
1460  **********************************************************************/
+
1461 
+
1462 // Equivalent class with empty methods, will be optimized out
+
1463 // while allowing to actually have calls implemented without WITH_CLUTCHLOG guards.
+
1464 #pragma GCC diagnostic push
+
1465 #pragma GCC diagnostic ignored "-Wreturn-type"
+
1466 class clutchlog
+
1467 {
+
1468  public:
+
1469  static clutchlog& logger() {}
+
1470  enum level {critical=0, error=1, warning=2, progress=3, note=4, info=5, debug=6, xdebug=7};
+
1471  class fmt {
+
1472  public:
+
1473  enum class ansi { colors_16, colors_256, colors_16M} mode;
+
1474  enum class typo { reset, bold, underline, inverse, none} style;
+
1475  enum class fg { black, red, green, yellow, blue, magenta, cyan, white, bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white, none} fore;
+
1476  enum class bg { black, red, green, yellow, blue, magenta, cyan, white, bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white, none } back;
+
1477  protected:
+
1478  friend std::ostream& operator<<(std::ostream&, const std::tuple<fg,bg,typo>&) {}
+
1479  friend std::ostream& operator<<(std::ostream&, const typo&) {}
+
1480  protected:
+
1481  struct color {
+
1482  ansi mode;
+
1483  enum class ground { fore, back } type;
+
1484  color(ansi a, ground g) : mode(a), type(g) {}
+
1485  virtual bool is_set() const = 0;
+
1486  virtual std::ostream& print_on( std::ostream&) const = 0;
+
1487  friend std::ostream& operator<<(std::ostream&, const color&) {}
+
1488  };
+
1489  struct color_256 : public color {
+
1490  short index;
+
1491  color_256(ground t) : color(ansi::colors_256, t), index(-1) {}
+
1492  color_256(ground t, const short i) : color(ansi::colors_256, t), index(i) {}
+
1493  bool is_set() const {}
+
1494  std::ostream& print_on( std::ostream&) const {}
1495  };
-
1496  struct fg_16M : public color_16M {
-
1497  fg_16M() : color_16M(ground::fore) {}
-
1498  fg_16M(short r, short g, short b) : color_16M(ground::fore, r,g,b) {}
-
1499  fg_16M(const std::string& srgb) : color_16M(ground::fore, srgb) {}
-
1500  fg_16M(const fg&) : color_16M(ground::fore, -1,-1,-1) {}
-
1501  } fore_16M;
-
1502  struct bg_16M : public color_16M {
-
1503  bg_16M() : color_16M(ground::back) {}
-
1504  bg_16M(short r, short g, short b) : color_16M(ground::back, r,g,b) {}
-
1505  bg_16M(const std::string& srgb) : color_16M(ground::back, srgb) {}
-
1506  bg_16M(const bg&) : color_16M(ground::back, -1,-1,-1) {}
-
1507  } back_16M;
-
1508  public:
-
1509  fmt() : mode(ansi::colors_16), style(typo::none), fore(fg::none), back(bg::none) {}
-
1510  fmt( fg f, bg b = bg::none, typo s = typo::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
1511  fmt( fg f, typo s , bg b = bg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
1512  fmt( bg b, fg f = fg::none, typo s = typo::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
1513  fmt( bg b, typo s , fg f = fg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
1514  fmt(typo s, fg f = fg::none, bg b = bg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
1515  fmt(typo s, bg b , fg f = fg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
-
1516  fmt(fg_256 f, bg_256 b, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(f), back_256(b) {}
-
1517  fmt(fg_256 f, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(f), back_256(bg::none) {}
-
1518  fmt(fg, bg_256 b, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(fg::none), back_256(b) {}
-
1519  fmt(const short fr, const short fg, const short fb,
-
1520  const short gr, const short gg, const short gb,
-
1521  typo s = typo::none)
-
1522  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(gr,gg,gb) {}
-
1523  fmt(fg,
-
1524  const short gr, const short gg, const short gb,
-
1525  typo s = typo::none)
-
1526  : mode(ansi::colors_16M), style(s), fore_16M(fg::none), back_16M(gr,gg,gb) {}
-
1527  fmt(const short fr, const short fg, const short fb,
-
1528  bg, typo s = typo::none)
-
1529  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(bg::none) {}
-
1530  fmt(const short fr, const short fg, const short fb,
-
1531  typo s = typo::none)
-
1532  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(bg::none) {}
-
1533 
-
1534  fmt(const std::string& f, const std::string& b, typo s = typo::none)
-
1535  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(b) {}
-
1536  fmt(fg, const std::string& b, typo s = typo::none)
-
1537  : mode(ansi::colors_16M), style(s), fore_16M(fg::none), back_16M(b) {}
-
1538  fmt(const std::string& f, bg, typo s = typo::none)
-
1539  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(bg::none) {}
-
1540  fmt(const std::string& f, typo s = typo::none)
-
1541  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(bg::none) {}
-
1542  protected:
-
1543  std::ostream& print_on( std::ostream&) const {}
-
1544  public:
-
1545  friend std::ostream& operator<<(std::ostream&, const fmt&) {}
-
1546  std::string operator()( const std::string&) const {}
-
1547  std::string str() const {}
-
1548  static fmt hash( const std::string&, const std::vector<fmt>) {}
-
1549  };
-
1550  public:
-
1551  clutchlog(clutchlog const&) = delete;
-
1552  void operator=(clutchlog const&) = delete;
-
1553  private:
-
1554  clutchlog() {}
-
1555  protected:
-
1556  struct scope_t {};
-
1557  scope_t locate(
-
1558  const level&,
-
1559  const std::string&,
-
1560  const std::string&,
-
1561  const size_t
-
1562  ) const
-
1563  {}
-
1564  public:
-
1565  void format(const std::string&) {}
-
1566  std::string format() const {}
-
1567 
-
1568  void format_comment(const std::string&) {}
-
1569  std::string format_comment() const {}
-
1570 
-
1571  void out(std::ostream&) {}
-
1572  std::ostream& out() {}
-
1573 
-
1574 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
1575  void depth(size_t) {}
-
1576  size_t depth() const {}
-
1577 
-
1578  void depth_mark(const std::string) {}
-
1579  std::string depth_mark() const {}
-
1580  void strip_calls(const size_t) {}
-
1581  size_t strip_calls() const {}
-
1582 #endif
-
1583 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
-
1584  void hfill_mark(const char) {}
-
1585  char hfill_mark() const {}
-
1586  void hfill_fmt(fmt) {}
-
1587  fmt hfill_fmt() const {}
-
1588  void hfill_min(const size_t) {}
-
1589  size_t hfill_min() {}
-
1590  void hfill_max(const size_t) {}
-
1591  size_t hfill_max() {}
-
1592 #endif
-
1593  void filehash_styles(std::vector<fmt> ) {}
-
1594  void funchash_styles(std::vector<fmt> ) {}
-
1595  void depth_styles(std::vector<fmt>) {}
-
1596 
-
1597  void threshold(level) {}
-
1598  void threshold(const std::string&) {}
-
1599  level threshold() const {}
-
1600  const std::map<std::string,level> levels() const {}
-
1601  level level_of(const std::string) {}
-
1602 
-
1603  void file(std::string) {}
-
1604  void func(std::string) {}
-
1605  void line(std::string) {}
-
1606 
-
1607 #pragma GCC diagnostic push
-
1608 #pragma GCC diagnostic ignored "-Wunused-parameter"
-
1609  void location(
-
1610  const std::string&,
-
1611  const std::string& in_function=".*",
-
1612  const std::string& in_line=".*"
-
1613  )
-
1614  {}
-
1615 #pragma GCC diagnostic pop
-
1616  template<class ... FMT>
-
1617  void style(level, FMT...) {}
-
1618  void style(level, fmt) {}
-
1619  fmt style(level) const {}
-
1620  public:
-
1621  std::string replace(
-
1622  const std::string&,
-
1623  const std::string&,
-
1624  const std::string&
-
1625  ) const
-
1626  {}
-
1627 
-
1628  std::string replace(
-
1629  const std::string&,
-
1630  const std::string&,
-
1631  const size_t
-
1632  ) const
-
1633  {}
-
1634 
-
1635  std::string format(
-
1636  std::string,
-
1637  const std::string&,
-
1638 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
1639  const std::string&,
-
1640 #endif
-
1641  const level&,
-
1642  const std::string&,
-
1643  const std::string&,
-
1644  const size_t
-
1645 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
1646  ,
-
1647  const size_t
-
1648 #endif
-
1649  ) const
-
1650  {}
-
1651 
-
1652  void log(
-
1653  const level&,
-
1654  const std::string&,
-
1655  const std::string&, const std::string&, size_t
-
1656  ) const
-
1657  {}
-
1658 
-
1659  template<class In>
-
1660  void dump(
-
1661  const level&,
-
1662  const In, const In,
-
1663  const std::string&, const std::string&, size_t,
-
1664  const std::string&,
-
1665  const std::string
-
1666  ) const
-
1667  {}
-
1668 };
-
1669 #pragma GCC diagnostic pop
-
1670 #endif // WITH_CLUTCHLOG
-
1671 
-
1672 #endif // CLUTCHLOG_H
+
1496  struct fg_256 : public color_256 {
+
1497  fg_256() : color_256(ground::fore) {}
+
1498  fg_256(const short f) : color_256(ground::fore, f) {}
+
1499  fg_256(const fg&) : color_256(ground::fore, -1) {}
+
1500  } fore_256;
+
1501  struct bg_256 : public color_256 {
+
1502  bg_256() : color_256(ground::back) {}
+
1503  bg_256(const short b) : color_256(ground::back, b) {}
+
1504  bg_256(const bg&) : color_256(ground::back, -1) {}
+
1505  } back_256;
+
1506  struct color_16M : public color {
+
1507  short red, green, blue;
+
1508  color_16M(ground t) : color(ansi::colors_16M, t), red(-1), green(-1), blue(-1) {}
+
1509  color_16M(ground t, short r, short g, short b) : color(ansi::colors_16M, t), red(r), green(g), blue(b) {}
+
1510  color_16M(ground t, const std::string&) : color(ansi::colors_16M, t) {}
+
1511  bool is_set() const {return red > -1 and green > -1 and blue > -1;}
+
1512  std::ostream& print_on( std::ostream&) const {}
+
1513  };
+
1514  struct fg_16M : public color_16M {
+
1515  fg_16M() : color_16M(ground::fore) {}
+
1516  fg_16M(short r, short g, short b) : color_16M(ground::fore, r,g,b) {}
+
1517  fg_16M(const std::string& srgb) : color_16M(ground::fore, srgb) {}
+
1518  fg_16M(const fg&) : color_16M(ground::fore, -1,-1,-1) {}
+
1519  } fore_16M;
+
1520  struct bg_16M : public color_16M {
+
1521  bg_16M() : color_16M(ground::back) {}
+
1522  bg_16M(short r, short g, short b) : color_16M(ground::back, r,g,b) {}
+
1523  bg_16M(const std::string& srgb) : color_16M(ground::back, srgb) {}
+
1524  bg_16M(const bg&) : color_16M(ground::back, -1,-1,-1) {}
+
1525  } back_16M;
+
1526  public:
+
1527  fmt() : mode(ansi::colors_16), style(typo::none), fore(fg::none), back(bg::none) {}
+
1528  fmt( fg f, bg b = bg::none, typo s = typo::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
1529  fmt( fg f, typo s , bg b = bg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
1530  fmt( bg b, fg f = fg::none, typo s = typo::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
1531  fmt( bg b, typo s , fg f = fg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
1532  fmt(typo s, fg f = fg::none, bg b = bg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
1533  fmt(typo s, bg b , fg f = fg::none) : mode(ansi::colors_16), style(s), fore(f), back(b) {}
+
1534  fmt(fg_256 f, bg_256 b, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(f), back_256(b) {}
+
1535  fmt(fg_256 f, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(f), back_256(bg::none) {}
+
1536  fmt(fg, bg_256 b, typo s = typo::none) : mode(ansi::colors_256), style(s), fore_256(fg::none), back_256(b) {}
+
1537  fmt(const short fr, const short fg, const short fb,
+
1538  const short gr, const short gg, const short gb,
+
1539  typo s = typo::none)
+
1540  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(gr,gg,gb) {}
+
1541  fmt(fg,
+
1542  const short gr, const short gg, const short gb,
+
1543  typo s = typo::none)
+
1544  : mode(ansi::colors_16M), style(s), fore_16M(fg::none), back_16M(gr,gg,gb) {}
+
1545  fmt(const short fr, const short fg, const short fb,
+
1546  bg, typo s = typo::none)
+
1547  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(bg::none) {}
+
1548  fmt(const short fr, const short fg, const short fb,
+
1549  typo s = typo::none)
+
1550  : mode(ansi::colors_16M), style(s), fore_16M(fr,fg,fb), back_16M(bg::none) {}
+
1551 
+
1552  fmt(const std::string& f, const std::string& b, typo s = typo::none)
+
1553  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(b) {}
+
1554  fmt(fg, const std::string& b, typo s = typo::none)
+
1555  : mode(ansi::colors_16M), style(s), fore_16M(fg::none), back_16M(b) {}
+
1556  fmt(const std::string& f, bg, typo s = typo::none)
+
1557  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(bg::none) {}
+
1558  fmt(const std::string& f, typo s = typo::none)
+
1559  : mode(ansi::colors_16M), style(s), fore_16M(f), back_16M(bg::none) {}
+
1560  protected:
+
1561  std::ostream& print_on( std::ostream&) const {}
+
1562  public:
+
1563  friend std::ostream& operator<<(std::ostream&, const fmt&) {}
+
1564  std::string operator()( const std::string&) const {}
+
1565  std::string str() const {}
+
1566  static fmt hash( const std::string&, const std::vector<fmt>) {}
+
1567  };
+
1568  public:
+
1569  clutchlog(clutchlog const&) = delete;
+
1570  void operator=(clutchlog const&) = delete;
+
1571  private:
+
1572  clutchlog() {}
+
1573  protected:
+
1574  struct scope_t {};
+
1575  scope_t locate(
+
1576  const level&,
+
1577  const std::string&,
+
1578  const std::string&,
+
1579  const size_t
+
1580  ) const
+
1581  {}
+
1582  public:
+
1583  void format(const std::string&) {}
+
1584  std::string format() const {}
+
1585 
+
1586  void format_comment(const std::string&) {}
+
1587  std::string format_comment() const {}
+
1588 
+
1589  void out(std::ostream&) {}
+
1590  std::ostream& out() {}
+
1591 
+
1592 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1593  void depth(size_t) {}
+
1594  size_t depth() const {}
+
1595 
+
1596  void depth_mark(const std::string) {}
+
1597  std::string depth_mark() const {}
+
1598  void strip_calls(const size_t) {}
+
1599  size_t strip_calls() const {}
+
1600 #endif
+
1601 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
+
1602  void hfill_mark(const char) {}
+
1603  char hfill_mark() const {}
+
1604  void hfill_fmt(fmt) {}
+
1605  fmt hfill_fmt() const {}
+
1606  void hfill_min(const size_t) {}
+
1607  size_t hfill_min() {}
+
1608  void hfill_max(const size_t) {}
+
1609  size_t hfill_max() {}
+
1610 #endif
+
1611  void filehash_styles(std::vector<fmt> ) {}
+
1612  void funchash_styles(std::vector<fmt> ) {}
+
1613  void depth_styles(std::vector<fmt>) {}
+
1614 
+
1615  void threshold(level) {}
+
1616  void threshold(const std::string&) {}
+
1617  level threshold() const {}
+
1618  const std::map<std::string,level> levels() const {}
+
1619  level level_of(const std::string) {}
+
1620 
+
1621  void file(std::string) {}
+
1622  void func(std::string) {}
+
1623  void line(std::string) {}
+
1624 
+
1625 #pragma GCC diagnostic push
+
1626 #pragma GCC diagnostic ignored "-Wunused-parameter"
+
1627  void location(
+
1628  const std::string&,
+
1629  const std::string& in_function=".*",
+
1630  const std::string& in_line=".*"
+
1631  )
+
1632  {}
+
1633 #pragma GCC diagnostic pop
+
1634  template<class ... FMT>
+
1635  void style(level, FMT...) {}
+
1636  void style(level, fmt) {}
+
1637  fmt style(level) const {}
+
1638  public:
+
1639  std::string replace(
+
1640  const std::string&,
+
1641  const std::string&,
+
1642  const std::string&
+
1643  ) const
+
1644  {}
+
1645 
+
1646  std::string replace(
+
1647  const std::string&,
+
1648  const std::string&,
+
1649  const size_t
+
1650  ) const
+
1651  {}
+
1652 
+
1653  std::string format(
+
1654  std::string,
+
1655  const std::string&,
+
1656 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1657  const std::string&,
+
1658 #endif
+
1659  const level&,
+
1660  const std::string&,
+
1661  const std::string&,
+
1662  const size_t
+
1663 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1664  ,
+
1665  const size_t
+
1666 #endif
+
1667  ) const
+
1668  {}
+
1669 
+
1670  void log(
+
1671  const level&,
+
1672  const std::string&,
+
1673  const std::string&, const std::string&, size_t
+
1674  ) const
+
1675  {}
+
1676 
+
1677  template<class In>
+
1678  void dump(
+
1679  const level&,
+
1680  const In, const In,
+
1681  const std::string&, const std::string&, size_t,
+
1682  const std::string&,
+
1683  const std::string
+
1684  ) const
+
1685  {}
+
1686 };
+
1687 #pragma GCC diagnostic pop
+
1688 #endif // WITH_CLUTCHLOG
+
1689 
+
1690 #endif // CLUTCHLOG_H
-
clutchlog::fmt::operator<<
friend std::ostream & operator<<(std::ostream &os, const std::tuple< fg, bg, typo > &fbs)
Output stream operator for a 3-tuple of 16-colors mode tags.
Definition: clutchlog.h:433
-
clutchlog::default_depth_mark
static std::string default_depth_mark
Default mark for stack depth.
Definition: clutchlog.h:249
-
clutchlog::_format_log
std::string _format_log
Current format of the standard output.
Definition: clutchlog.h:913
-
clutchlog::fmt::color_16M::color_16M
color_16M(ground t, const std::string &srgb)
Hex triplet string constructor.
Definition: clutchlog.h:601
-
clutchlog::depth_styles
void depth_styles(std::vector< fmt > styles)
Set the styles for value-dependant depth formatting.
Definition: clutchlog.h:1045
-
clutchlog::_level_fmt
std::map< level, fmt > _level_fmt
Dictionary of level identifier to their format.
Definition: clutchlog.h:911
-
clutchlog::log
void log(const level &stage, const std::string &what, const std::string &file, const std::string &func, size_t line) const
Print a log message IF the location matches the given one.
Definition: clutchlog.h:1356
+
clutchlog::fmt::operator<<
friend std::ostream & operator<<(std::ostream &os, const std::tuple< fg, bg, typo > &fbs)
Output stream operator for a 3-tuple of 16-colors mode tags.
Definition: clutchlog.h:443
+
clutchlog::default_depth_mark
static std::string default_depth_mark
Default mark for stack depth.
Definition: clutchlog.h:259
+
clutchlog::_format_log
std::string _format_log
Current format of the standard output.
Definition: clutchlog.h:923
+
clutchlog::fmt::color_16M::color_16M
color_16M(ground t, const std::string &srgb)
Hex triplet string constructor.
Definition: clutchlog.h:611
+
clutchlog::dump
void dump(const level &stage, const In container_begin, const In container_end, const std::string &file, const std::string &func, const size_t line, const std::string &filename_template="dump_{n}.dat", const std::string sep=dump_default_sep) const
Dump a serializable container after a comment line with log information.
Definition: clutchlog.h:1399
+
clutchlog::depth_styles
void depth_styles(std::vector< fmt > styles)
Set the styles for value-dependant depth formatting.
Definition: clutchlog.h:1055
+
clutchlog::_level_fmt
std::map< level, fmt > _level_fmt
Dictionary of level identifier to their format.
Definition: clutchlog.h:921
clutchlog::fmt::back
enum clutchlog::fmt::bg back
Background color.
-
clutchlog::_funchash_fmts
std::vector< fmt > _funchash_fmts
List of candidate format objects for value-dependant function name styling.
Definition: clutchlog.h:946
-
clutchlog::fmt::str
std::string str() const
Return the formatting code as a string.
Definition: clutchlog.h:807
-
clutchlog::fmt::fg_256
Foreground in 256-colors mode.
Definition: clutchlog.h:539
-
clutchlog::line
void line(std::string line)
Set the regular expression filtering the line location.
Definition: clutchlog.h:1075
-
clutchlog::fmt::color::operator<<
friend std::ostream & operator<<(std::ostream &os, const color &c)
Print the actually encoded escaped color sequence on the given stream.
Definition: clutchlog.h:493
-
clutchlog::fmt::operator<<
friend std::ostream & operator<<(std::ostream &os, const typo &s)
Output stream operator for a typo tag alone, in 16-colors mode.
Definition: clutchlog.h:455
-
clutchlog::dump_default_format
static std::string dump_default_format
Default format of the comment line in file dump.
Definition: clutchlog.h:235
-
clutchlog::out
void out(std::ostream &out)
Set the output stream on which to print.
Definition: clutchlog.h:977
-
clutchlog::fmt::color_16M::is_set
bool is_set() const
Returns true if the underying representation encodes an existing color.
Definition: clutchlog.h:623
-
clutchlog::fmt::fg_16M::fg_16M
fg_16M(const fg &)
Conversion constructor from 16-colors mode.
Definition: clutchlog.h:659
-
clutchlog::dump_default_sep
static std::string dump_default_sep
Default item separator for dump.
Definition: clutchlog.h:242
-
clutchlog::format
std::string format(std::string row, const std::string &what, const level &stage, const std::string &file, const std::string &func, const size_t line) const
Substitute all tags in the format string with the corresponding information and apply the style corre...
Definition: clutchlog.h:1259
-
clutchlog::fmt::bg_256
Background in 256-colors mode.
Definition: clutchlog.h:556
-
CLUTCHLOG_DEFAULT_DEPTH_MARK
#define CLUTCHLOG_DEFAULT_DEPTH_MARK
Compile-time default mark for stack depth.
Definition: clutchlog.h:246
-
clutchlog::default_strip_calls
static unsigned int default_strip_calls
Number of call stack levels to remove from depth display by default.
Definition: clutchlog.h:256
-
clutchlog::default_hfill_min
static size_t default_hfill_min
Default minimum width (number of characters) at which to fill for right-aligning the right part of me...
Definition: clutchlog.h:277
-
clutchlog::replace
std::string replace(const std::string &form, const std::string &mark, const std::string &tag) const
Replace mark by tag in form.
Definition: clutchlog.h:1183
-
clutchlog::fmt::color_256::color_256
color_256(ground t)
Constructor.
Definition: clutchlog.h:518
+
clutchlog::_funchash_fmts
std::vector< fmt > _funchash_fmts
List of candidate format objects for value-dependant function name styling.
Definition: clutchlog.h:956
+
clutchlog::fmt::str
std::string str() const
Return the formatting code as a string.
Definition: clutchlog.h:817
+
clutchlog::fmt::fg_256
Foreground in 256-colors mode.
Definition: clutchlog.h:549
+
clutchlog::line
void line(std::string line)
Set the regular expression filtering the line location.
Definition: clutchlog.h:1085
+
clutchlog::fmt::color::operator<<
friend std::ostream & operator<<(std::ostream &os, const color &c)
Print the actually encoded escaped color sequence on the given stream.
Definition: clutchlog.h:503
+
clutchlog::fmt::operator<<
friend std::ostream & operator<<(std::ostream &os, const typo &s)
Output stream operator for a typo tag alone, in 16-colors mode.
Definition: clutchlog.h:465
+
clutchlog::dump_default_format
static std::string dump_default_format
Default format of the comment line in file dump.
Definition: clutchlog.h:245
+
clutchlog::out
void out(std::ostream &out)
Set the output stream on which to print.
Definition: clutchlog.h:987
+
clutchlog::fmt::color_16M::is_set
bool is_set() const
Returns true if the underying representation encodes an existing color.
Definition: clutchlog.h:633
+
clutchlog::fmt::fg_16M::fg_16M
fg_16M(const fg &)
Conversion constructor from 16-colors mode.
Definition: clutchlog.h:669
+
clutchlog::dump_default_sep
static std::string dump_default_sep
Default item separator for dump.
Definition: clutchlog.h:252
+
clutchlog::format
std::string format(std::string row, const std::string &what, const level &stage, const std::string &file, const std::string &func, const size_t line) const
Substitute all tags in the format string with the corresponding information and apply the style corre...
Definition: clutchlog.h:1269
+
clutchlog::fmt::bg_256
Background in 256-colors mode.
Definition: clutchlog.h:566
+
CLUTCHLOG_DEFAULT_DEPTH_MARK
#define CLUTCHLOG_DEFAULT_DEPTH_MARK
Compile-time default mark for stack depth.
Definition: clutchlog.h:256
+
clutchlog::default_strip_calls
static unsigned int default_strip_calls
Number of call stack levels to remove from depth display by default.
Definition: clutchlog.h:266
+
clutchlog::default_hfill_min
static size_t default_hfill_min
Default minimum width (number of characters) at which to fill for right-aligning the right part of me...
Definition: clutchlog.h:287
+
clutchlog::replace
std::string replace(const std::string &form, const std::string &mark, const std::string &tag) const
Replace mark by tag in form.
Definition: clutchlog.h:1193
+
clutchlog::fmt::color_256::color_256
color_256(ground t)
Constructor.
Definition: clutchlog.h:528
clutchlog::fmt::back_16M
clutchlog::fmt::bg_16M back_16M
Current background in 16M-colors mode.
-
clutchlog::fmt::color
Interface class for colors representation.
Definition: clutchlog.h:470
+
clutchlog::fmt::color
Interface class for colors representation.
Definition: clutchlog.h:480
clutchlog::fmt::ansi::colors_16
@ colors_16
16 colors mode.
-
clutchlog::fmt::bg_16M
background in 256-colors mode.
Definition: clutchlog.h:664
-
clutchlog::default_hfill_char
static char default_hfill_char
Default character used as a filling for right-align the right part of messages with "{hfill}".
Definition: clutchlog.h:263
-
clutchlog::scope_t::matches
bool matches
Everything is compatible.
Definition: clutchlog.h:1110
+
clutchlog::fmt::bg_16M
background in 256-colors mode.
Definition: clutchlog.h:674
+
clutchlog::default_hfill_char
static char default_hfill_char
Default character used as a filling for right-align the right part of messages with "{hfill}".
Definition: clutchlog.h:273
+
clutchlog::scope_t::matches
bool matches
Everything is compatible.
Definition: clutchlog.h:1120
clutchlog::fmt::style
enum clutchlog::fmt::typo style
Typographic style.
-
clutchlog::fmt::color_16M
Abstract base class for 16M colors objects (24-bits ANSI).
Definition: clutchlog.h:573
-
clutchlog::fmt::fg_256::fg_256
fg_256(const fg &)
Conversion constructor from 16-colors mode.
Definition: clutchlog.h:551
-
clutchlog::format_comment
void format_comment(const std::string &format)
Set the template string for dumps.
Definition: clutchlog.h:972
-
clutchlog::fmt::bg_16M::bg_16M
bg_16M(const std::string &srgb)
Hex triplet string constructor.
Definition: clutchlog.h:684
-
clutchlog::file
void file(std::string file)
Set the regular expression filtering the file location.
Definition: clutchlog.h:1071
-
clutchlog::locate
scope_t locate(const level &stage, const std::string &file, const std::string &func, const size_t line) const
Gather information on the current location of the call.
Definition: clutchlog.h:1132
+
clutchlog::fmt::color_16M
Abstract base class for 16M colors objects (24-bits ANSI).
Definition: clutchlog.h:583
+
clutchlog::fmt::fg_256::fg_256
fg_256(const fg &)
Conversion constructor from 16-colors mode.
Definition: clutchlog.h:561
+
clutchlog::format_comment
void format_comment(const std::string &format)
Set the template string for dumps.
Definition: clutchlog.h:982
+
clutchlog::fmt::bg_16M::bg_16M
bg_16M(const std::string &srgb)
Hex triplet string constructor.
Definition: clutchlog.h:694
+
clutchlog::file
void file(std::string file)
Set the regular expression filtering the file location.
Definition: clutchlog.h:1081
+
clutchlog::locate
scope_t locate(const level &stage, const std::string &file, const std::string &func, const size_t line) const
Gather information on the current location of the call.
Definition: clutchlog.h:1142
clutchlog::fmt::fore_16M
clutchlog::fmt::fg_16M fore_16M
Current foreground in 16M-colors mode.
-
clutchlog::fmt::color_256
Abstract base class for 256 colors objects (8-bits ANSI).
Definition: clutchlog.h:509
-
clutchlog::fmt::fmt
fmt()
Empty constructor, only useful for a no-op formatter.
Definition: clutchlog.h:697
-
clutchlog::style
void style(level stage, fmt style)
Set the style (color and typo) of the given log level, passing a fmt instance.
Definition: clutchlog.h:1096
-
clutchlog::threshold
void threshold(level l)
Set the log level (below which logs are not printed) with an identifier.
Definition: clutchlog.h:1048
-
clutchlog::threshold
level threshold() const
Get the log level below which logs are not printed.
Definition: clutchlog.h:1052
+
clutchlog::fmt::color_256
Abstract base class for 256 colors objects (8-bits ANSI).
Definition: clutchlog.h:519
+
clutchlog::fmt::fmt
fmt()
Empty constructor, only useful for a no-op formatter.
Definition: clutchlog.h:707
+
clutchlog::style
void style(level stage, fmt style)
Set the style (color and typo) of the given log level, passing a fmt instance.
Definition: clutchlog.h:1106
+
clutchlog::threshold
void threshold(level l)
Set the log level (below which logs are not printed) with an identifier.
Definition: clutchlog.h:1058
+
clutchlog::threshold
level threshold() const
Get the log level below which logs are not printed.
Definition: clutchlog.h:1062
clutchlog::fmt::color::is_set
virtual bool is_set() const =0
Should return true if the underying representation encodes an existing color.
-
clutchlog::_level_short
std::map< level, std::string > _level_short
dictionary of level identifier to their 4-letters representation.
Definition: clutchlog.h:909
-
clutchlog::level
level
Available log levels.
Definition: clutchlog.h:303
-
clutchlog::fmt::color_256::color_256
color_256(ground t, const short i)
Constructor.
Definition: clutchlog.h:525
-
clutchlog::fmt::color_256::print_on
std::ostream & print_on(std::ostream &os) const
Print the color index on the given stream.
Definition: clutchlog.h:531
-
clutchlog::fmt::color_16M::color_16M
color_16M(ground t)
Constructor.
Definition: clutchlog.h:582
-
clutchlog::default_hfill_max
static size_t default_hfill_max
Default maximum width (number of characters) for which to fill for right-aligning the right part of m...
Definition: clutchlog.h:275
-
clutchlog::funchash_styles
void funchash_styles(std::vector< fmt > styles)
Set the candidate styles for value-dependant function name formatting.
Definition: clutchlog.h:1036
-
clutchlog::scope_t::scope_t
scope_t()
Constructor.
Definition: clutchlog.h:1120
-
clutchlog::_in_func
std::regex _in_func
Current function location filter.
Definition: clutchlog.h:939
-
clutchlog::default_format
static std::string default_format
Default format of the messages.
Definition: clutchlog.h:213
-
clutchlog::fmt::bg_16M::bg_16M
bg_16M(short r, short g, short b)
Numeric triplet constructor.
Definition: clutchlog.h:676
-
clutchlog::logger
static clutchlog & logger()
Get the logger instance.
Definition: clutchlog.h:296
-
clutchlog::fmt::fg_16M
Foreground in 256-colors mode.
Definition: clutchlog.h:634
-
clutchlog::dump
void dump(const level &stage, const In container_begin, const In container_end, const std::string &file, const std::string &func, size_t line, const std::string &filename_template="dump_{n}.dat", const std::string sep=dump_default_sep) const
Dump a serializable container after a comment line with log information.
Definition: clutchlog.h:1381
+
clutchlog::_level_short
std::map< level, std::string > _level_short
dictionary of level identifier to their 4-letters representation.
Definition: clutchlog.h:919
+
clutchlog::level
level
Available log levels.
Definition: clutchlog.h:313
+
clutchlog::fmt::color_256::color_256
color_256(ground t, const short i)
Constructor.
Definition: clutchlog.h:535
+
clutchlog::fmt::color_256::print_on
std::ostream & print_on(std::ostream &os) const
Print the color index on the given stream.
Definition: clutchlog.h:541
+
clutchlog::fmt::color_16M::color_16M
color_16M(ground t)
Constructor.
Definition: clutchlog.h:592
+
clutchlog::default_hfill_max
static size_t default_hfill_max
Default maximum width (number of characters) for which to fill for right-aligning the right part of m...
Definition: clutchlog.h:285
+
clutchlog::funchash_styles
void funchash_styles(std::vector< fmt > styles)
Set the candidate styles for value-dependant function name formatting.
Definition: clutchlog.h:1046
+
clutchlog::scope_t::scope_t
scope_t()
Constructor.
Definition: clutchlog.h:1130
+
clutchlog::_in_func
std::regex _in_func
Current function location filter.
Definition: clutchlog.h:949
+
clutchlog::default_format
static std::string default_format
Default format of the messages.
Definition: clutchlog.h:223
+
clutchlog::fmt::bg_16M::bg_16M
bg_16M(short r, short g, short b)
Numeric triplet constructor.
Definition: clutchlog.h:686
+
clutchlog::logger
static clutchlog & logger()
Get the logger instance.
Definition: clutchlog.h:306
+
clutchlog::fmt::fg_16M
Foreground in 256-colors mode.
Definition: clutchlog.h:644
clutchlog::fmt::fore_256
clutchlog::fmt::fg_256 fore_256
Current foreground in 256-colors mode.
clutchlog::fmt::fore
enum clutchlog::fmt::fg fore
Foreground color.
-
clutchlog::filehash_styles
void filehash_styles(std::vector< fmt > styles)
Set the candidate styles for value-dependant file name formatting.
Definition: clutchlog.h:1028
+
clutchlog::filehash_styles
void filehash_styles(std::vector< fmt > styles)
Set the candidate styles for value-dependant file name formatting.
Definition: clutchlog.h:1038
clutchlog::fmt::color::type
enum clutchlog::fmt::color::ground type
Type of color (foreground or background).
-
clutchlog::fmt
Color and style formatter for ANSI terminal escape sequences.
Definition: clutchlog.h:366
-
clutchlog::fmt::color_256::index
short index
The encoded color index in 4-bits ANSI.
Definition: clutchlog.h:513
-
clutchlog::fmt::bg_256::bg_256
bg_256()
Empty constructor: no color.
Definition: clutchlog.h:558
-
clutchlog::func
void func(std::string func)
Set the regular expression filtering the function location.
Definition: clutchlog.h:1073
-
clutchlog::format
std::string format() const
Get the template string.
Definition: clutchlog.h:969
-
clutchlog::_in_file
std::regex _in_file
Current file location filter.
Definition: clutchlog.h:937
-
clutchlog::style
void style(level stage, FMT... styles)
Set the style (color and typo) of the given log level.
Definition: clutchlog.h:1094
-
clutchlog::fmt::bg_256::bg_256
bg_256(const bg &)
Conversion constructor from 16-colors mode.
Definition: clutchlog.h:568
-
clutchlog::fmt::fg_16M::fg_16M
fg_16M()
Empty constructor: no color.
Definition: clutchlog.h:636
-
clutchlog::level_of
level level_of(const std::string name)
Return the log level tag corresponding to the given pre-configured name.
Definition: clutchlog.h:1060
-
clutchlog::_level_word
const std::map< level, std::string > _level_word
Dictionary of level identifier to their string representation.
Definition: clutchlog.h:905
-
clutchlog::fmt::operator()
std::string operator()(const std::string &msg) const
Format the given string with the currently encoded format.
Definition: clutchlog.h:795
-
clutchlog::fmt::color_16M::color_16M
color_16M(ground t, short r, short g, short b)
Numeric triplet constructor.
Definition: clutchlog.h:591
-
clutchlog::fmt::color_16M::print_on
std::ostream & print_on(std::ostream &os) const
Print the color RGB triplet on the given stream.
Definition: clutchlog.h:626
-
clutchlog::fmt::bg
bg
Background color codes.
Definition: clutchlog.h:411
-
CLUTCHLOG_DEFAULT_FORMAT
#define CLUTCHLOG_DEFAULT_FORMAT
Compile-time default format of the messages (debug mode: with absolute location).
Definition: clutchlog.h:198
-
clutchlog::_in_line
std::regex _in_line
Current line location filter.
Definition: clutchlog.h:941
-
clutchlog::fmt::fg_256::fg_256
fg_256(const short f)
Constructor.
Definition: clutchlog.h:546
+
clutchlog::fmt
Color and style formatter for ANSI terminal escape sequences.
Definition: clutchlog.h:376
+
clutchlog::fmt::color_256::index
short index
The encoded color index in 4-bits ANSI.
Definition: clutchlog.h:523
+
clutchlog::fmt::bg_256::bg_256
bg_256()
Empty constructor: no color.
Definition: clutchlog.h:568
+
clutchlog::func
void func(std::string func)
Set the regular expression filtering the function location.
Definition: clutchlog.h:1083
+
clutchlog::format
std::string format() const
Get the template string.
Definition: clutchlog.h:979
+
clutchlog::_in_file
std::regex _in_file
Current file location filter.
Definition: clutchlog.h:947
+
clutchlog::style
void style(level stage, FMT... styles)
Set the style (color and typo) of the given log level.
Definition: clutchlog.h:1104
+
clutchlog::fmt::bg_256::bg_256
bg_256(const bg &)
Conversion constructor from 16-colors mode.
Definition: clutchlog.h:578
+
clutchlog::fmt::fg_16M::fg_16M
fg_16M()
Empty constructor: no color.
Definition: clutchlog.h:646
+
clutchlog::level_of
level level_of(const std::string name)
Return the log level tag corresponding to the given pre-configured name.
Definition: clutchlog.h:1070
+
clutchlog::_level_word
const std::map< level, std::string > _level_word
Dictionary of level identifier to their string representation.
Definition: clutchlog.h:915
+
clutchlog::fmt::operator()
std::string operator()(const std::string &msg) const
Format the given string with the currently encoded format.
Definition: clutchlog.h:805
+
clutchlog::fmt::color_16M::color_16M
color_16M(ground t, short r, short g, short b)
Numeric triplet constructor.
Definition: clutchlog.h:601
+
clutchlog::fmt::color_16M::print_on
std::ostream & print_on(std::ostream &os) const
Print the color RGB triplet on the given stream.
Definition: clutchlog.h:636
+
clutchlog::fmt::bg
bg
Background color codes.
Definition: clutchlog.h:421
+
CLUTCHLOG_DEFAULT_FORMAT
#define CLUTCHLOG_DEFAULT_FORMAT
Compile-time default format of the messages (debug mode: with absolute location).
Definition: clutchlog.h:208
+
clutchlog::_in_line
std::regex _in_line
Current line location filter.
Definition: clutchlog.h:951
+
clutchlog::fmt::fg_256::fg_256
fg_256(const short f)
Constructor.
Definition: clutchlog.h:556
clutchlog::fmt::ansi::colors_256
@ colors_256
256 colors mode.
clutchlog::fmt::mode
enum clutchlog::fmt::ansi mode
Current ANSI color mode.
-
clutchlog::replace
std::string replace(const std::string &form, const std::string &mark, const size_t tag) const
Replace mark by tag in form, converting tag to its string representation first.
Definition: clutchlog.h:1248
-
clutchlog::format_comment
std::string format_comment() const
Get the template string for dumps.
Definition: clutchlog.h:974
-
clutchlog::fmt::fg_256::fg_256
fg_256()
Empty constructor: no color.
Definition: clutchlog.h:541
+
clutchlog::replace
std::string replace(const std::string &form, const std::string &mark, const size_t tag) const
Replace mark by tag in form, converting tag to its string representation first.
Definition: clutchlog.h:1258
+
clutchlog::format_comment
std::string format_comment() const
Get the template string for dumps.
Definition: clutchlog.h:984
+
clutchlog::fmt::fg_256::fg_256
fg_256()
Empty constructor: no color.
Definition: clutchlog.h:551
clutchlog::fmt::ansi::colors_16M
@ colors_16M
16 millions ("true") colors mode.
-
clutchlog::_format_dump
std::string _format_dump
Current format of the file output.
Definition: clutchlog.h:915
-
CLUTCHDUMP_DEFAULT_SEP
#define CLUTCHDUMP_DEFAULT_SEP
Compile-time default item separator for dump.
Definition: clutchlog.h:239
-
clutchlog::fmt::bg_256::bg_256
bg_256(const short b)
Constructor.
Definition: clutchlog.h:563
-
clutchlog::fmt::color::ground
ground
Codes for representing foreground or background.
Definition: clutchlog.h:474
-
clutchlog::scope_t
Structure holding a location matching.
Definition: clutchlog.h:1108
-
CLUTCHLOG_DEFAULT_HFILL_MARK
#define CLUTCHLOG_DEFAULT_HFILL_MARK
Character used as a filling for right-align the right part of messages with "{hfill}".
Definition: clutchlog.h:260
-
clutchlog::fmt::print_on
std::ostream & print_on(std::ostream &os) const
Print the currently encoded format escape code on the given output stream.
Definition: clutchlog.h:746
-
clutchlog::fmt::color_256::is_set
bool is_set() const
Returns true if the underying representation encodes an existing color.
Definition: clutchlog.h:528
-
clutchlog::_out
std::ostream * _out
Standard output.
Definition: clutchlog.h:927
-
clutchlog::out
std::ostream & out()
Get the output stream on which to print.
Definition: clutchlog.h:979
-
clutchlog::threshold
void threshold(const std::string &l)
Set the log level (below which logs are not printed) with a string.
Definition: clutchlog.h:1050
+
clutchlog::_format_dump
std::string _format_dump
Current format of the file output.
Definition: clutchlog.h:925
+
CLUTCHDUMP_DEFAULT_SEP
#define CLUTCHDUMP_DEFAULT_SEP
Compile-time default item separator for dump.
Definition: clutchlog.h:249
+
clutchlog::fmt::bg_256::bg_256
bg_256(const short b)
Constructor.
Definition: clutchlog.h:573
+
clutchlog::fmt::color::ground
ground
Codes for representing foreground or background.
Definition: clutchlog.h:484
+
clutchlog::scope_t
Structure holding a location matching.
Definition: clutchlog.h:1118
+
CLUTCHLOG_DEFAULT_HFILL_MARK
#define CLUTCHLOG_DEFAULT_HFILL_MARK
Character used as a filling for right-align the right part of messages with "{hfill}".
Definition: clutchlog.h:270
+
clutchlog::fmt::print_on
std::ostream & print_on(std::ostream &os) const
Print the currently encoded format escape code on the given output stream.
Definition: clutchlog.h:756
+
clutchlog::fmt::color_256::is_set
bool is_set() const
Returns true if the underying representation encodes an existing color.
Definition: clutchlog.h:538
+
clutchlog::_out
std::ostream * _out
Standard output.
Definition: clutchlog.h:937
+
clutchlog::out
std::ostream & out()
Get the output stream on which to print.
Definition: clutchlog.h:989
+
clutchlog::threshold
void threshold(const std::string &l)
Set the log level (below which logs are not printed) with a string.
Definition: clutchlog.h:1060
clutchlog::fmt::color::print_on
virtual std::ostream & print_on(std::ostream &os) const =0
Should print the underlying representation on the given stream.
-
clutchlog::levels
const std::map< std::string, level > & levels() const
Get the map of available log levels string representations toward their identifier....
Definition: clutchlog.h:1054
-
clutchlog::_strip_calls
size_t _strip_calls
Current number of call stack levels to remove from depth display.
Definition: clutchlog.h:903
-
clutchlog::scope_t::stage
level stage
Current log level.
Definition: clutchlog.h:1112
-
clutchlog::scope_t::there
bool there
Location is compatible.
Definition: clutchlog.h:1118
-
clutchlog::fmt::fg_16M::fg_16M
fg_16M(const std::string &srgb)
Hex triplet string constructor.
Definition: clutchlog.h:654
-
CLUTCHLOG_STRIP_CALLS
#define CLUTCHLOG_STRIP_CALLS
Compile-time number of call stack levels to remove from depth display by default.
Definition: clutchlog.h:253
-
clutchlog::fmt::operator<<
friend std::ostream & operator<<(std::ostream &os, const fmt &fmt)
Output stream overload.
Definition: clutchlog.h:780
-
clutchlog::fmt::bg_16M::bg_16M
bg_16M(const bg &)
Conversion constructor from 16-colors mode.
Definition: clutchlog.h:689
-
clutchlog::fmt::bg_16M::bg_16M
bg_16M()
Empty constructor: no color.
Definition: clutchlog.h:666
-
clutchlog::_word_level
std::map< std::string, level > _word_level
Dictionary of level string to their identifier.
Definition: clutchlog.h:907
-
clutchlog::_stage
level _stage
Current log level.
Definition: clutchlog.h:935
-
clutchlog::style
fmt style(level stage) const
Get the configured fmt instance of the given log level.
Definition: clutchlog.h:1098
-
clutchlog::fmt::typo
typo
Typographic style codes.
Definition: clutchlog.h:379
-
clutchlog::location
void location(const std::string &in_file, const std::string &in_function=".*", const std::string &in_line=".*")
Set the regular expressions filtering the location.
Definition: clutchlog.h:1078
+
clutchlog::levels
const std::map< std::string, level > & levels() const
Get the map of available log levels string representations toward their identifier....
Definition: clutchlog.h:1064
+
clutchlog::_strip_calls
size_t _strip_calls
Current number of call stack levels to remove from depth display.
Definition: clutchlog.h:913
+
clutchlog::scope_t::stage
level stage
Current log level.
Definition: clutchlog.h:1122
+
clutchlog::scope_t::there
bool there
Location is compatible.
Definition: clutchlog.h:1128
+
clutchlog::fmt::fg_16M::fg_16M
fg_16M(const std::string &srgb)
Hex triplet string constructor.
Definition: clutchlog.h:664
+
CLUTCHLOG_STRIP_CALLS
#define CLUTCHLOG_STRIP_CALLS
Compile-time number of call stack levels to remove from depth display by default.
Definition: clutchlog.h:263
+
clutchlog::fmt::operator<<
friend std::ostream & operator<<(std::ostream &os, const fmt &fmt)
Output stream overload.
Definition: clutchlog.h:790
+
clutchlog::log
void log(const level &stage, const std::string &what, const std::string &file, const std::string &func, const size_t line, const size_t depth_delta=0) const
Print a log message IF the location matches the given one.
Definition: clutchlog.h:1374
+
clutchlog::fmt::bg_16M::bg_16M
bg_16M(const bg &)
Conversion constructor from 16-colors mode.
Definition: clutchlog.h:699
+
clutchlog::fmt::bg_16M::bg_16M
bg_16M()
Empty constructor: no color.
Definition: clutchlog.h:676
+
clutchlog::_word_level
std::map< std::string, level > _word_level
Dictionary of level string to their identifier.
Definition: clutchlog.h:917
+
clutchlog::_stage
level _stage
Current log level.
Definition: clutchlog.h:945
+
clutchlog::style
fmt style(level stage) const
Get the configured fmt instance of the given log level.
Definition: clutchlog.h:1108
+
clutchlog::fmt::typo
typo
Typographic style codes.
Definition: clutchlog.h:389
+
clutchlog::location
void location(const std::string &in_file, const std::string &in_function=".*", const std::string &in_line=".*")
Set the regular expressions filtering the location.
Definition: clutchlog.h:1088
CLUTCHLOG_HAVE_UNIX_SYSINFO
#define CLUTCHLOG_HAVE_UNIX_SYSINFO
True if POSIX headers necessary for stack depth management are available.
Definition: clutchlog.h:33
-
clutchlog::_filehash_fmts
std::vector< fmt > _filehash_fmts
List of candidate format objects for value-dependant file name styling.
Definition: clutchlog.h:944
-
clutchlog
The single class which holds everything.
Definition: clutchlog.h:177
-
clutchlog::fmt::ansi
ansi
ANSI code configuring the available number of colors.
Definition: clutchlog.h:369
-
clutchlog::fmt::fg_16M::fg_16M
fg_16M(short r, short g, short b)
Numeric triplet constructor.
Definition: clutchlog.h:646
-
clutchlog::fmt::fg
fg
Foreground color codes.
Definition: clutchlog.h:390
-
clutchlog::fmt::color_16M::red
short red
The encoded RGB indices.
Definition: clutchlog.h:577
-
CLUTCHDUMP_DEFAULT_FORMAT
#define CLUTCHDUMP_DEFAULT_FORMAT
Compile-time default format of the comment line in file dump.
Definition: clutchlog.h:221
-
clutchlog::fmt::color::color
color(ansi a, ground g)
Constructor.
Definition: clutchlog.h:484
+
clutchlog::_filehash_fmts
std::vector< fmt > _filehash_fmts
List of candidate format objects for value-dependant file name styling.
Definition: clutchlog.h:954
+
clutchlog
The single class which holds everything.
Definition: clutchlog.h:187
+
clutchlog::fmt::ansi
ansi
ANSI code configuring the available number of colors.
Definition: clutchlog.h:379
+
clutchlog::fmt::fg_16M::fg_16M
fg_16M(short r, short g, short b)
Numeric triplet constructor.
Definition: clutchlog.h:656
+
clutchlog::fmt::fg
fg
Foreground color codes.
Definition: clutchlog.h:400
+
clutchlog::fmt::color_16M::red
short red
The encoded RGB indices.
Definition: clutchlog.h:587
+
CLUTCHDUMP_DEFAULT_FORMAT
#define CLUTCHDUMP_DEFAULT_FORMAT
Compile-time default format of the comment line in file dump.
Definition: clutchlog.h:231
+
clutchlog::fmt::color::color
color(ansi a, ground g)
Constructor.
Definition: clutchlog.h:494
clutchlog::fmt::back_256
clutchlog::fmt::bg_256 back_256
Current background in 256-colors mode.
@@ -84,7 +84,7 @@ $(document).ready(function(){initNavTree('dir_59425e443f801f1f2fd8bbe4959a3ccf.h
-

tests → clutchlog Relation

Public Member Functions

std::cout << error("ERROR") << std::endl;
Note
A formatter called this way WILL output a reset escape code at the end.
-

Definition at line 795 of file clutchlog.h.

+

Definition at line 805 of file clutchlog.h.

-

References print_on().

+

References print_on().

@@ -462,7 +462,7 @@ std::ostream & 
std::cout << error << "ERROR" << end << std::endl;
Note
An formatter called this way will NOT output a reset escape code.
-

Definition at line 780 of file clutchlog.h.

+

Definition at line 790 of file clutchlog.h.

@@ -497,7 +497,7 @@ std::ostream & 
Definition at line 369 of file clutchlog.h.

+

Definition at line 379 of file clutchlog.h.

@@ -506,7 +506,7 @@ std::ostream & 
Color and style formatter for ANSI terminal escape sequences.
Definition: clutchlog.h:366
+
Color and style formatter for ANSI terminal escape sequences.
Definition: clutchlog.h:376
clutchlog -  0.14 +  0.15
clutchlog -  0.14 +  0.15
CLUTCHLOC   __FILE__, __FUNCTION__, __LINE__
 Handy shortcuts to location.
 
#define CLUTCHLOG(LEVEL, WHAT)
 Log a message at the given level. More...
#define CLUTCHLOGD(LEVEL, WHAT, DEPTH_DELTA)
 Log a message at the given level and with a given depth delta. More...
 
+#define CLUTCHLOG(LEVEL, WHAT)   CLUTCHLOGD(LEVEL, WHAT, 0)
 Log a message at the given level.
 
#define CLUTCHDUMP(LEVEL, CONTAINER, FILENAME)
 Dump the given container. More...
clutchlog -  0.14 +  0.15
clutchlog -  0.14 +  0.15
File in testsIncludes file in clutchlog
t-assert.cppclutchlog.h
t-color.cppclutchlog.h
t-color16M.cppclutchlog.h
t-color256.cppclutchlog.h
t-demo-extravagant.cppclutchlog.h
t-demo.cppclutchlog.h
t-dump.cppclutchlog.h
t-fmt-constructors.cppclutchlog.h
t-hash-color.cppclutchlog.h
t-log.cppclutchlog.h
t-one-line-if.cppclutchlog.h
+

tests → clutchlog Relation

File in testsIncludes file in clutchlog
t-assert.cppclutchlog.h
t-color.cppclutchlog.h
t-color16M.cppclutchlog.h
t-color256.cppclutchlog.h
t-demo-extravagant.cppclutchlog.h
t-demo.cppclutchlog.h
t-depth-delta.cppclutchlog.h
t-dump.cppclutchlog.h
t-fmt-constructors.cppclutchlog.h
t-hash-color.cppclutchlog.h
t-log.cppclutchlog.h
t-one-line-if.cppclutchlog.h
diff --git a/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.map b/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.map index 903a130..bb0a10c 100644 --- a/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.map +++ b/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.map @@ -1,5 +1,5 @@ - + diff --git a/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.md5 b/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.md5 index 2919850..0ad8513 100644 --- a/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.md5 +++ b/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.md5 @@ -1 +1 @@ -16d7faff1b9c3198b20cf3ae5437a2db \ No newline at end of file +531b57d09121179fe636e2cda048c80c \ No newline at end of file diff --git a/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.svg b/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.svg index 211c012..57a16f0 100644 --- a/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.svg +++ b/docs/dir_59425e443f801f1f2fd8bbe4959a3ccf_dep.svg @@ -32,8 +32,8 @@ dir_59425e443f801f1f2fd8bbe4959a3ccf->dir_c318bd5cf14aaa5601e6029e0b5b4048 - -11 + +12 diff --git a/docs/dir_c318bd5cf14aaa5601e6029e0b5b4048.html b/docs/dir_c318bd5cf14aaa5601e6029e0b5b4048.html index 8a19fbd..abfa9b5 100644 --- a/docs/dir_c318bd5cf14aaa5601e6029e0b5b4048.html +++ b/docs/dir_c318bd5cf14aaa5601e6029e0b5b4048.html @@ -28,7 +28,7 @@ Logo
clutchlog -  0.14 +  0.15
diff --git a/docs/files.html b/docs/files.html index 7ec8eeb..f535eb4 100644 --- a/docs/files.html +++ b/docs/files.html @@ -28,7 +28,7 @@ Logo
clutchlog -  0.14 +  0.15
@@ -97,11 +97,12 @@ $(document).ready(function(){initNavTree('files.html',''); initResizable(); });  t-color256.cpp  t-demo-extravagant.cpp  t-demo.cpp - t-dump.cpp - t-fmt-constructors.cpp - t-hash-color.cpp - t-log.cpp - t-one-line-if.cpp + t-depth-delta.cpp + t-dump.cpp + t-fmt-constructors.cpp + t-hash-color.cpp + t-log.cpp + t-one-line-if.cpp diff --git a/docs/files_dup.js b/docs/files_dup.js index bda5401..de394c4 100644 --- a/docs/files_dup.js +++ b/docs/files_dup.js @@ -7,6 +7,7 @@ var files_dup = [ "t-color256.cpp", "t-color256_8cpp_source.html", null ], [ "t-demo-extravagant.cpp", "t-demo-extravagant_8cpp_source.html", null ], [ "t-demo.cpp", "t-demo_8cpp_source.html", null ], + [ "t-depth-delta.cpp", "t-depth-delta_8cpp_source.html", null ], [ "t-dump.cpp", "t-dump_8cpp_source.html", null ], [ "t-fmt-constructors.cpp", "t-fmt-constructors_8cpp_source.html", null ], [ "t-hash-color.cpp", "t-hash-color_8cpp_source.html", null ], diff --git a/docs/functions.html b/docs/functions.html index b3457b8..7ae6bc1 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -28,7 +28,7 @@ Logo
clutchlog -  0.14 +  0.15
@@ -197,7 +197,7 @@ $(document).ready(function(){initNavTree('functions.html',''); initResizable(); : clutchlog
  • dump() -: clutchlog +: clutchlog
  • dump_default_format : clutchlog @@ -290,7 +290,7 @@ $(document).ready(function(){initNavTree('functions.html',''); initResizable(); : clutchlog
  • log() -: clutchlog +: clutchlog
  • logger() : clutchlog diff --git a/docs/functions_enum.html b/docs/functions_enum.html index c268733..3dccd46 100644 --- a/docs/functions_enum.html +++ b/docs/functions_enum.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    diff --git a/docs/functions_func.html b/docs/functions_func.html index 955935c..eab349f 100644 --- a/docs/functions_func.html +++ b/docs/functions_func.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    @@ -114,7 +114,7 @@ $(document).ready(function(){initNavTree('functions_func.html',''); initResizabl : clutchlog
  • dump() -: clutchlog +: clutchlog
  • @@ -176,7 +176,7 @@ $(document).ready(function(){initNavTree('functions_func.html',''); initResizabl : clutchlog
  • log() -: clutchlog +: clutchlog
  • logger() : clutchlog diff --git a/docs/functions_rela.html b/docs/functions_rela.html index 42d1030..c2eefc2 100644 --- a/docs/functions_rela.html +++ b/docs/functions_rela.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    diff --git a/docs/functions_vars.html b/docs/functions_vars.html index c5212bc..d4a0507 100644 --- a/docs/functions_vars.html +++ b/docs/functions_vars.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    diff --git a/docs/globals.html b/docs/globals.html index 30cf2a9..918f052 100644 --- a/docs/globals.html +++ b/docs/globals.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    @@ -130,6 +130,9 @@ $(document).ready(function(){initNavTree('globals.html',''); initResizable(); })
  • CLUTCHLOG_STRIP_CALLS : clutchlog.h
  • +
  • CLUTCHLOGD +: clutchlog.h +
  • WITH_CLUTCHLOG : clutchlog.h
  • diff --git a/docs/globals_defs.html b/docs/globals_defs.html index 222ec62..a0cb07e 100644 --- a/docs/globals_defs.html +++ b/docs/globals_defs.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    @@ -130,6 +130,9 @@ $(document).ready(function(){initNavTree('globals_defs.html',''); initResizable(
  • CLUTCHLOG_STRIP_CALLS : clutchlog.h
  • +
  • CLUTCHLOGD +: clutchlog.h +
  • WITH_CLUTCHLOG : clutchlog.h
  • diff --git a/docs/graph_legend.html b/docs/graph_legend.html index 8e89892..edb553d 100644 --- a/docs/graph_legend.html +++ b/docs/graph_legend.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    diff --git a/docs/group___default_config.html b/docs/group___default_config.html index 3453ca4..fe42a2a 100644 --- a/docs/group___default_config.html +++ b/docs/group___default_config.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    diff --git a/docs/group___formating.html b/docs/group___formating.html index f29caec..5bbe894 100644 --- a/docs/group___formating.html +++ b/docs/group___formating.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    diff --git a/docs/group___main.html b/docs/group___main.html index f62f38f..80a0c24 100644 --- a/docs/group___main.html +++ b/docs/group___main.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    diff --git a/docs/group___main.js b/docs/group___main.js index 9920517..c1d2ac0 100644 --- a/docs/group___main.js +++ b/docs/group___main.js @@ -1,11 +1,11 @@ var group___main = [ [ "clutchlog", "classclutchlog.html", [ - [ "System-dependent stack depth", "index.html#autotoc_md24", null ], - [ "System-dependent horizontal fill", "index.html#autotoc_md25", null ], - [ "Dependencies", "index.html#autotoc_md26", null ], - [ "Variable names within the CLUTCHLOG macro", "index.html#autotoc_md27", null ], - [ "Features", "index.html#autotoc_md28", null ], + [ "System-dependent stack depth", "index.html#autotoc_md26", null ], + [ "System-dependent horizontal fill", "index.html#autotoc_md27", null ], + [ "Dependencies", "index.html#autotoc_md28", null ], + [ "Variable names within the CLUTCHLOG macro", "index.html#autotoc_md29", null ], + [ "Features", "index.html#autotoc_md30", null ], [ "scope_t", "structclutchlog_1_1scope__t.html", [ [ "scope_t", "structclutchlog_1_1scope__t.html#a0f1d865ffcf17f215e5559cdd2690572", null ], [ "matches", "structclutchlog_1_1scope__t.html#ae6c0e4ed20db797124ed1e5faa033ad9", null ], @@ -41,8 +41,8 @@ var group___main = [ "replace", "classclutchlog.html#a972f895c70edc335f3018a2c8971d59e", null ], [ "replace", "classclutchlog.html#ae90d5a1a428587ad67b38b2ea4ca9fa2", null ], [ "format", "classclutchlog.html#abd692cca9a2e772e7c9d6531bb3c7761", null ], - [ "log", "classclutchlog.html#a23dbb98f0d3c5cc21c232cde16cf317a", null ], - [ "dump", "classclutchlog.html#a63308e8deae3cfec6801318203494143", null ], + [ "log", "classclutchlog.html#a14c19e17c54d6353ba34c0dc3371094a", null ], + [ "dump", "classclutchlog.html#ab72a0adc9ff287270afe09c9da825fdb", null ], [ "default_format", "classclutchlog.html#a0c4ac57601e6f8d146fd5cc060968ecc", null ], [ "dump_default_format", "classclutchlog.html#ace879554298e6e6e36dafef330c27be8", null ], [ "dump_default_sep", "classclutchlog.html#af898bffe23b125245e338d7495c76d45", null ], diff --git a/docs/group___use_macros.html b/docs/group___use_macros.html index 359c78e..dfca8d2 100644 --- a/docs/group___use_macros.html +++ b/docs/group___use_macros.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    @@ -98,8 +98,12 @@ Macros #define CLUTCHLOC   __FILE__, __FUNCTION__, __LINE__  Handy shortcuts to location.
      -#define CLUTCHLOG(LEVEL, WHAT) - Log a message at the given level. More...
    +#define CLUTCHLOGD(LEVEL, WHAT, DEPTH_DELTA) + Log a message at the given level and with a given depth delta. More...
    +  + +#define CLUTCHLOG(LEVEL, WHAT)   CLUTCHLOGD(LEVEL, WHAT, 0) + Log a message at the given level.
      #define CLUTCHDUMP(LEVEL, CONTAINER, FILENAME)  Dump the given container. More...
    @@ -112,14 +116,14 @@ Macros  

    Macro Definition Documentation

    - -

    ◆ CLUTCHLOG

    + +

    ◆ CLUTCHLOGD

    - + @@ -128,7 +132,13 @@ Macros - + + + + + + + @@ -137,13 +147,13 @@ Macros
    #define CLUTCHLOG#define CLUTCHLOGD (   LEVEL,
     WHAT WHAT,
     DEPTH_DELTA 
    -Value:
    do { \
    -
    auto& clutchlog__logger = clutchlog::logger(); \
    -
    std::ostringstream clutchlog__msg ; clutchlog__msg << WHAT; \
    -
    clutchlog__logger.log(clutchlog::level::LEVEL, clutchlog__msg.str(), CLUTCHLOC); \
    +Value:
    do { \
    +
    auto& clutchlog__logger = clutchlog::logger(); \
    +
    std::ostringstream clutchlog__msg ; clutchlog__msg << WHAT; \
    +
    clutchlog__logger.log(clutchlog::level::LEVEL, clutchlog__msg.str(), CLUTCHLOC, DEPTH_DELTA); \
    } while(0)
    -

    Log a message at the given level.

    +

    Log a message at the given level and with a given depth delta.

    Definition at line 81 of file clutchlog.h.

    @@ -188,7 +198,7 @@ Macros

    Dump the given container.

    -

    Definition at line 98 of file clutchlog.h.

    +

    Definition at line 107 of file clutchlog.h.

    @@ -233,7 +243,7 @@ Macros

    Call any function if the scope matches.

    -

    Definition at line 115 of file clutchlog.h.

    +

    Definition at line 124 of file clutchlog.h.

    @@ -272,15 +282,15 @@ Macros

    Run any code if the scope matches.

    -

    Definition at line 136 of file clutchlog.h.

    +

    Definition at line 145 of file clutchlog.h.

    -
    static clutchlog & logger()
    Get the logger instance.
    Definition: clutchlog.h:296
    +
    static clutchlog & logger()
    Get the logger instance.
    Definition: clutchlog.h:306
    #define CLUTCHLOC
    Handy shortcuts to location.
    Definition: clutchlog.h:77
    -
    #define CLUTCHDUMP_DEFAULT_SEP
    Compile-time default item separator for dump.
    Definition: clutchlog.h:239
    +
    #define CLUTCHDUMP_DEFAULT_SEP
    Compile-time default item separator for dump.
    Definition: clutchlog.h:249

    Clutchlog is a spatial logging system that targets versatile debugging. It allows to (de)clutch messages for a given: log level, source code location or call stack depth.

    @@ -232,12 +234,15 @@ Output Configuration
  • {file}: the current file (absolute path),
  • {func}: the current function,
  • {line}: the current line number,
  • -
  • {level_fmt}: the format of the current level (i.e. configured with clutchlog::style).
  • +
  • {level_fmt}: the style of the current level (i.e. configured with clutchlog::style),
  • +
  • {filehash_fmt}: a style for file names, which is value-dependant (see clutchlog::filehash_styles),
  • +
  • {funchash_fmt}: a style for function names, which is value-dependant (see clutchlog::funchash_styles).
  • Some tags are only available on POSIX operating systems as of now:

    • {name}: the name of the current binary,
    • {depth}: the current depth of the call stack,
    • {depth_marks}: as many chevrons > as there is calls in the stack,
    • +
    • {depth_fmt}: a style depending on the current depth value (see clutchlog::depth_styles),
    • {hfill}: 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.

    @@ -245,8 +250,9 @@ Log Format

    The default log format is "[{name}] {level_letter}:{depth_marks} {msg} {hfill} {func} @ {file}:{line}\n", it can be overriden at compile time by defining the CLUTCHLOG_DEFAULT_FORMAT macro.

    By default, and if CLUTCHLOG_DEFAULT_FORMAT is not defined, clutchlog will not put the location-related tags in the message formats (i.e. {name}, {func}, and {line}) when not in Debug builds.

    -Output style

    -

    Output lines can be colored differently depending on the log level.

    // Print error messages in bold red:
    +Output Styling +

    Output lines can be styled differently depending on their content.

    +

    For example, output lines can be colored differently depending on the log level.

    // Print error messages in bold red:
    log.style(level::error, // First, the log level.
    fmt::fg::red, // Then the styles, in any order...
    fmt::typo::bold);
    @@ -261,7 +267,7 @@ Output style
  • numeric triplets or web hex strings will encode a 16 million ("true") colors mode,
  • clutchlog::fg::none and clutchlog::bg::none can be passed in all modes.
  • -

    For example, all the following lines encode a bright red foreground for the critical level:

    log.style(level:critical,
    +

    For example, all the following lines encode a bright red foreground for the critical level (see the "Colors" section below):

    log.style(level:critical,
    fmt::fg::red); // 16-colors mode.
    log.style(level:critical,
    255); // 256-colors mode.
    @@ -335,28 +341,42 @@ Colors

    In 16M-colors mode, if you want to only encode the background color, you cannot just omit the foreground color, you have to pass a fg::none tag as first argument.

    log.style(level::info, fg::none, 100,0,0); // No color over dark red.
    log.style(level::info, fg::none, 100,0,0, typo::bold); // No color over bold dark red.
    -

    +

    +Value-dependant Format Tags

    +

    Some tags can be used to change the style of (part of) the output line,

    +

    depending on its content. The {filehash_fmt} and {funchash_fmt} will introduce a styling sequence which depends on the current file name, and function name respectively. The chosen style is chosen at random among the candidate ones, but will always be the same for each value.

    +

    The set of candidate styles can be configured with clutchlog::filehash_styles and clutchlog::funchash_styles, which both take a vector of clutchlog::fmt objects as argument:

    // Either one or the other color for filenames:
    +
    log.filehash_styles( { fmt(fg::red), fmt(fg::yellow) } );
    +
    // This would fix the function name style to a single one:
    +
    log.funchash_styles( { fmt(typo::bold) } );
    +
    // Works with any `fmt` constructor
    +
    // (here, shades of blues in 256-colors mode):
    +
    log.funchash_styles( { fmt(33), fmt(27), fmt(39), fmt(45) } );
    +

    The same idea applies to {depth_fmt}. However, if clutchlog::depth_styles is configured, then the styles are chosen in order. That is, a depth of 1 would lead to the first style being chosen. If the current depth of the stack is larger than the number of configured styles, then the last one is used. For example:

    // Increasingly darker depth level colors (using the 256-colors mode).
    +
    log.depth_styles({ fmt(255), fmt(250), fmt(245), fmt(240), fmt(235) });
    +

    If clutchlog::depth_styles is set, the {depth_marks} template tag will render with each mark having each own style corresponding to its depth. Note: a depth of zero showing no mark, the first style in the list is never applied to marks.

    +

    Advanced Usage

    -

    +

    More Output Configuration

    -

    +

    Dump Format

    The default format of the first line of comment added with the dump macro is "# [{name}] {level} in {func} (at depth {depth}) @ {file}:{line}". It can be edited with the format_comment method. If it is set to an empty string, then no comment line is added. The default can be modified at compile time with CLUTCHDUMP_DEFAULT_FORMAT.

    By default, the separator between items in the container is a new line. To change this behaviour, you can change CLUTCHDUMP_DEFAULT_SEP or call the low-level dump method.

    By default, and if CLUTCHDUMP_DEFAULT_FORMAT is not defined, clutchlog will not put the location-related tags in the message formats (i.e. {file} and {line}) when not in Debug builds.

    -

    +

    Stack Depth Mark

    The mark used with the {depth_marks} tag can be configured with the clutchlog::depth_mark method, and its default with the CLUTCHLOG_DEFAULT_DEPTH_MARK macro:

    log.depth_mark(CLUTCHLOG_DEFAULT_DEPTH_MARK); // Defaults to ">".
    -

    +

    Horizontal Filling

    The character used with the {hfill} tag can be configured wth the clutchlog::hfill_mark method, and its default with the CLUTCHLOG_DEFAULT_HFILL_MARK macro:

    log.hfill_mark(CLUTCHLOG_DEFAULT_HFILL_MARK); // Defaults to '.'.

    Clutchlog measures the width of the standard error channel. If it is redirected, it may be measured as very large (or very small). Thus, the clutchlog::hfill_min clutchlog::hfill_max accessors allow to set a minimum and a maximum width (in number of characters).

    log.hfill_max(CLUTCHLOG_DEFAULT_HFILL_MAX); // Defaults to 300.
    log.hfill_min(CLUTCHLOG_DEFAULT_HFILL_MIN); // Defaults to 150.

    Note: clutchlog will use the measured width, unless it goes out of [clutchlog::hfill_min,clutchlog::hfill_max], in which case it will be caped to those bounds.

    -

    +

    Stack Depth

    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, or calling clutchlog::strip_calls.

    log.strip_calls(CLUTCHLOG_STRIP_CALLS); // Defaults to 5.
    -

    +

    Disabled calls

    By default, clutchlog is always enabled if the NDEBUG preprocessor variable is not defined (this variable is set by CMake in build types that differs from Debug).

    You can however force clutchlog to be enabled in any build type by setting the WITH_CLUTCHLOG preprocessor variable.

    @@ -365,26 +385,32 @@ Disabled calls
    #define CLUTCHLOG_DEFAULT_DEPTH_BUILT_NODEBUG clutchlog::level::xdebug

    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.

    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.

    -

    +

    Low-level API

    All configuration setters have a getters counterpart, with the same name but taking no parameter, for example:

    std::string mark = log.depth_mark();
    -

    To control more precisely the logging, one can use the low-level clutchlog::log method:

    log.log(clutchlog::level::xdebug, "hello world", "main.cpp", "main", 122);
    +

    To control more precisely the logging, one can use the low-level clutchlog::log method:

    log.log(clutchlog::level::xdebug, "hello world", "main.cpp", "main", 122);

    A helper macro can helps to fill in the location with the actual one, as seen by the compiler:

    log.log(clutchlog::level::xdebug, "hello world", CLUTCHLOC);

    A similar dump method exists:

    log.dump(clutchlog::level::xdebug, cont.begin(), cont.end(), CLUTCHLOC, "dumped_{n}.dat", "\n");
    log.dump(clutchlog::level::xdebug, cont.begin(), cont.end(), "main.cpp", "main", 122, "dumped.dat", "\n\n");

    You can access the identifier of log levels with clutchlog::level_of:

    log.threshold( log.level_of("XDebug") ); // You have to know the exact string.
    -

    +

    (De)clutch any function call

    The CLUTHFUNC macro allows to wrap any function within the current logger.

    For instance, this can be useful if you want to (de)clutch calls to asserts. To do that, just declare your own macro:

    #define ASSERT(...) { CLUTCHFUNC(error, assert, __VA_ARGS__) }

    Thus, any call like ASSERT(x > 3); will be declutchable with the same configuration than a call to CLUTCHLOG.

    -

    +

    (De)clutch any code section

    The CLUTCHCODE macro allows to wrap any code within the current logger.

    For instance:

    std::clog << "We are clutched!\n";
    );
    -

    +

    +Manually Increase Stack Depth

    +

    You may want to manually increase the stack depth for a given logging call, for instance to subdivise a single function in sections. To do so, you can use the CLUTCHLOGD macro, which take an additional argument, in the form of the number of additional (fake) stack depths you want:

    CLUTCHLOG( debug, "Call"); // Regular macro.
    +
    CLUTCHLOGD(debug, "Sub call", 1); // Adds an additional (fake) stack depth.
    +
    CLUTCHLOGD(debug, "Sub sub!", 2); // Adds two additional (fake) stack depths.
    +

    That way, the depth will be rendered to the actual depth, plus the additional depth delta. Note that the displayed function will stay the same. Any filtering on the stack depth will take into account the fake depth and not the real one.

    +

    Examples

    Here what you would do to setup clutchlog with the default configuration:

    auto& log = clutchlog::logger();
    log.out(std::clog);
    @@ -456,29 +482,29 @@ Examples
    log.hfill_char('.');
    log.hfill_max(300);
    log.hfill_style(clutchlog::fmt::fg::none);
    -

    +

    Limitations

    -

    +

    System-dependent stack depth

    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: 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:

    #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
    log.depth( x );
    #endif
    -

    +

    System-dependent horizontal fill

    Because access to the current terminal width is system-dependent, the {hfill} format tag feature is only available for operating systems having the following headers: sys/ioctl.h, stdio.h and unistd.h (so far, tested with Linux).

    Clutchlog sets the CLUTCHLOG_HAVE_UNIX_SYSIOCTL to 1 if the headers are available, and to 0 if they are not. You can make portable code using something like:

    #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
    log.hfill_mark( '_' );
    #endif

    If you use unicode characters in your template, the horizontal width will not be computed properly, resulting in incorrectly right-aligned lines. Solving this would require the use of third-party libraries, making portability more difficult.

    -

    +

    Dependencies

    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.

    -

    +

    Variable names within the CLUTCHLOG macro

    Calling the CLUTCHLOG macro with a message using a variable named clutchlog__msg will end in an error.

    -

    +

    Features

    What Clutchlog do not provide at the moment (but may in a near future):

    -

    +

    Build and tests

    To use clutchlog, just include its header in your code and either ensure that the NDEBUG preprocessor variable is not set, either define the WITH_CLUTCHLOG preprocessor variable.

    If you're using CMake (or another modern build system), it will unset NDEBUG —and thus enable clutchlog— only for the "Debug" build type, which is usually what you want if you use clutchlog, anyway.

    @@ -507,17 +533,18 @@ Build and tests -
    #define CLUTCHLOG_DEFAULT_DEPTH_MARK
    Compile-time default mark for stack depth.
    Definition: clutchlog.h:246
    +
    #define CLUTCHLOG_DEFAULT_DEPTH_MARK
    Compile-time default mark for stack depth.
    Definition: clutchlog.h:256
    enum clutchlog::fmt::typo style
    Typographic style.
    -
    #define CLUTCHDUMP(LEVEL, CONTAINER, FILENAME)
    Dump the given container.
    Definition: clutchlog.h:98
    -
    static clutchlog & logger()
    Get the logger instance.
    Definition: clutchlog.h:296
    -
    Color and style formatter for ANSI terminal escape sequences.
    Definition: clutchlog.h:366
    +
    #define CLUTCHLOGD(LEVEL, WHAT, DEPTH_DELTA)
    Log a message at the given level and with a given depth delta.
    Definition: clutchlog.h:81
    +
    #define CLUTCHDUMP(LEVEL, CONTAINER, FILENAME)
    Dump the given container.
    Definition: clutchlog.h:107
    +
    static clutchlog & logger()
    Get the logger instance.
    Definition: clutchlog.h:306
    +
    Color and style formatter for ANSI terminal escape sequences.
    Definition: clutchlog.h:376
    #define CLUTCHLOC
    Handy shortcuts to location.
    Definition: clutchlog.h:77
    -
    #define CLUTCHLOG_DEFAULT_HFILL_MARK
    Character used as a filling for right-align the right part of messages with "{hfill}".
    Definition: clutchlog.h:260
    -
    #define CLUTCHLOG(LEVEL, WHAT)
    Log a message at the given level.
    Definition: clutchlog.h:81
    -
    #define CLUTCHFUNC(LEVEL, FUNC,...)
    Call any function if the scope matches.
    Definition: clutchlog.h:115
    -
    #define CLUTCHLOG_STRIP_CALLS
    Compile-time number of call stack levels to remove from depth display by default.
    Definition: clutchlog.h:253
    -
    #define CLUTCHCODE(LEVEL,...)
    Run any code if the scope matches.
    Definition: clutchlog.h:136
    +
    #define CLUTCHLOG_DEFAULT_HFILL_MARK
    Character used as a filling for right-align the right part of messages with "{hfill}".
    Definition: clutchlog.h:270
    +
    #define CLUTCHLOG(LEVEL, WHAT)
    Log a message at the given level.
    Definition: clutchlog.h:98
    +
    #define CLUTCHFUNC(LEVEL, FUNC,...)
    Call any function if the scope matches.
    Definition: clutchlog.h:124
    +
    #define CLUTCHLOG_STRIP_CALLS
    Compile-time number of call stack levels to remove from depth display by default.
    Definition: clutchlog.h:263
    +
    #define CLUTCHCODE(LEVEL,...)
    Run any code if the scope matches.
    Definition: clutchlog.h:145
    + + + + + + + + +
    + +
    +
    +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    +
    t-depth-delta.cpp
    +
    +
    +
    1 #include <iostream>
    +
    2 #include <limits>
    +
    3 
    +
    4 #include "../clutchlog/clutchlog.h"
    +
    5 
    +
    6 void deepcall()
    +
    7 {
    +
    8  CLUTCHLOG(warning,"at depth 4");
    +
    9  CLUTCHLOGD(warning,"at depth 4+1", 1);
    +
    10  CLUTCHLOGD(warning,"at depth 4+2", 2);
    +
    11 }
    +
    12 
    +
    13 void subsubsubcall()
    +
    14 {
    +
    15  CLUTCHLOG(warning,"at depth 3");
    +
    16  CLUTCHLOGD(warning,"at depth 3+1", 1);
    +
    17  CLUTCHLOGD(warning,"at depth 3+2", 2);
    +
    18  deepcall();
    +
    19 }
    +
    20 
    +
    21 void subsubcall()
    +
    22 {
    +
    23  CLUTCHLOG(warning,"at depth 2");
    +
    24  CLUTCHLOGD(warning,"at depth 2+1", 1);
    +
    25  CLUTCHLOGD(warning,"at depth 2+2", 2);
    +
    26  subsubsubcall();
    +
    27 }
    +
    28 
    +
    29 void subcall()
    +
    30 {
    +
    31  CLUTCHLOG(warning,"at depth 1");
    +
    32  CLUTCHLOGD(warning,"at depth 1+1", 1);
    +
    33  CLUTCHLOGD(warning,"at depth 1+2", 2);
    +
    34  subsubcall();
    +
    35 }
    +
    36 
    +
    37 int main(/*const int argc, char* argv[]*/)
    +
    38 {
    +
    39  auto& log = clutchlog::logger();
    +
    40  using fmt = clutchlog::fmt;
    +
    41  using typo = clutchlog::fmt::typo;
    +
    42 
    +
    43  fmt reset(typo::reset);
    +
    44  std::ostringstream tpl;
    +
    45  tpl << "{depth_fmt}{depth} {depth_marks}"
    +
    46  << reset << "{funchash_fmt}in {func} {msg}\t\n";
    +
    47  log.format(tpl.str());
    +
    48  log.threshold(clutchlog::level::xdebug);
    +
    49  std::vector<fmt> greys = {fmt(15)};
    +
    50  for(unsigned short i=255; i > 231; i-=3) {
    +
    51  greys.push_back( fmt(i) ); }
    +
    52  log.depth_styles( greys );
    +
    53  log.depth_mark("| ");
    +
    54 
    +
    55  CLUTCHLOG(warning,"in main");
    +
    56  subcall();
    +
    57 }
    +
    58 
    +
    +
    +
    #define CLUTCHLOGD(LEVEL, WHAT, DEPTH_DELTA)
    Log a message at the given level and with a given depth delta.
    Definition: clutchlog.h:81
    +
    static clutchlog & logger()
    Get the logger instance.
    Definition: clutchlog.h:306
    +
    Color and style formatter for ANSI terminal escape sequences.
    Definition: clutchlog.h:376
    +
    #define CLUTCHLOG(LEVEL, WHAT)
    Log a message at the given level.
    Definition: clutchlog.h:98
    +
    typo
    Typographic style codes.
    Definition: clutchlog.h:389
    + + + + diff --git a/docs/t-dump_8cpp_source.html b/docs/t-dump_8cpp_source.html index 86d4bdd..b9fbeba 100644 --- a/docs/t-dump_8cpp_source.html +++ b/docs/t-dump_8cpp_source.html @@ -28,7 +28,7 @@ Logo
    clutchlog -  0.14 +  0.15
    @@ -111,8 +111,8 @@ $(document).ready(function(){initNavTree('t-dump_8cpp_source.html',''); initResi
    21 }
    -
    #define CLUTCHDUMP(LEVEL, CONTAINER, FILENAME)
    Dump the given container.
    Definition: clutchlog.h:98
    -
    static clutchlog & logger()
    Get the logger instance.
    Definition: clutchlog.h:296
    +
    #define CLUTCHDUMP(LEVEL, CONTAINER, FILENAME)
    Dump the given container.
    Definition: clutchlog.h:107
    +
    static clutchlog & logger()
    Get the logger instance.
    Definition: clutchlog.h:306
    -
    Color and style formatter for ANSI terminal escape sequences.
    Definition: clutchlog.h:366
    -
    bg
    Background color codes.
    Definition: clutchlog.h:411
    -
    typo
    Typographic style codes.
    Definition: clutchlog.h:379
    -
    fg
    Foreground color codes.
    Definition: clutchlog.h:390
    +
    Color and style formatter for ANSI terminal escape sequences.
    Definition: clutchlog.h:376
    +
    bg
    Background color codes.
    Definition: clutchlog.h:421
    +
    typo
    Typographic style codes.
    Definition: clutchlog.h:389
    +
    fg
    Foreground color codes.
    Definition: clutchlog.h:400
    -
    static clutchlog & logger()
    Get the logger instance.
    Definition: clutchlog.h:296
    -
    Color and style formatter for ANSI terminal escape sequences.
    Definition: clutchlog.h:366
    -
    #define CLUTCHLOG(LEVEL, WHAT)
    Log a message at the given level.
    Definition: clutchlog.h:81
    -
    typo
    Typographic style codes.
    Definition: clutchlog.h:379
    +
    static clutchlog & logger()
    Get the logger instance.
    Definition: clutchlog.h:306
    +
    Color and style formatter for ANSI terminal escape sequences.
    Definition: clutchlog.h:376
    +
    #define CLUTCHLOG(LEVEL, WHAT)
    Log a message at the given level.
    Definition: clutchlog.h:98
    +
    typo
    Typographic style codes.
    Definition: clutchlog.h:389
    -
    static clutchlog & logger()
    Get the logger instance.
    Definition: clutchlog.h:296
    -
    #define CLUTCHLOG(LEVEL, WHAT)
    Log a message at the given level.
    Definition: clutchlog.h:81
    +
    static clutchlog & logger()
    Get the logger instance.
    Definition: clutchlog.h:306
    +
    #define CLUTCHLOG(LEVEL, WHAT)
    Log a message at the given level.
    Definition: clutchlog.h:98
    -
    #define CLUTCHLOG(LEVEL, WHAT)
    Log a message at the given level.
    Definition: clutchlog.h:81
    +
    #define CLUTCHLOG(LEVEL, WHAT)
    Log a message at the given level.
    Definition: clutchlog.h:98