-
Go to the documentation of this file. 1 #ifndef __CLUTCHLOG_H__
-
2 #define __CLUTCHLOG_H__
-
+
Go to the documentation of this file.
+
+
@@ -241,7 +241,7 @@ $(function() {
199 #ifndef CLUTCHLOG_DEFAULT_FORMAT
200 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
202 #define CLUTCHLOG_DEFAULT_FORMAT "{level_letter}:{depth_marks} {msg} {hfill} {func}\n"
+
202 #define CLUTCHLOG_DEFAULT_FORMAT "[{name}] {level_letter}:{depth_marks} {msg} {hfill} {func}\n"
204 #define CLUTCHLOG_DEFAULT_FORMAT "{level_letter} {msg}\t\t\t\t\t{func}\n"
@@ -287,724 +287,767 @@ $(function() {
255 #define CLUTCHLOG_HFILL_MARK '.'
257 #endif // CLUTCHLOG_HFILL_MARK
-
+
-
-
-
-
-
-
-
-
-
280 enum level {critical=0, error=1, warning=2, progress=3, note=4, info=5, debug=6, xdebug=7};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
262 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
+
263 #ifndef CLUTCHLOG_HFILL_MAX
+
264 #define CLUTCHLOG_HFILL_MAX 300
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
293 enum level {critical=0, error=1, warning=2, progress=3, note=4, info=5, debug=6, xdebug=7};
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
348 std::vector<int> codes; codes.reserve(3);
-
349 if(this->
fore != fg::none) { codes.push_back(
static_cast<int>(this->
fore ));}
-
350 if(this->
back != bg::none) { codes.push_back(
static_cast<int>(this->
back ));}
-
351 if(this->
style != typo::none) { codes.push_back(
static_cast<int>(this->
style));}
-
352 if(codes.size() == 0) {
return os;}
-
-
-
355 assert(codes.size() > 0);
-
-
357 for(
size_t i=1; i < codes.size(); ++i) {
-
358 os <<
";" << codes[i];
-
-
-
-
-
-
-
-
-
-
-
-
-
-
393 std::ostringstream os;
-
-
395 fmt reset(fmt::typo::reset);
-
-
-
-
-
-
-
-
-
410 void operator=(
clutchlog const&) =
delete;
-
-
-
-
-
-
-
417 {level::critical,
"Critical"},
-
418 {level::error ,
"Error"},
-
419 {level::warning ,
"Warning"},
-
420 {level::progress,
"Progress"},
-
421 {level::note ,
"Note"},
-
422 {level::info ,
"Info"},
-
423 {level::debug ,
"Debug"},
-
424 {level::xdebug ,
"XDebug"}
-
-
-
427 {level::critical,fmt(fmt::fg::red, fmt::typo::underline)},
-
428 {level::error ,fmt(fmt::fg::red, fmt::typo::bold)},
-
429 {level::warning ,fmt(fmt::fg::magenta, fmt::typo::bold)},
-
430 {level::progress,fmt()},
-
431 {level::note ,fmt()},
-
432 {level::info ,fmt()},
-
433 {level::debug ,fmt()},
-
434 {level::xdebug ,fmt()}
-
-
-
-
-
-
440 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
441 _depth(std::numeric_limits<size_t>::max() -
_strip_calls),
-
-
-
-
-
-
-
-
-
-
-
-
453 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
-
-
455 ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
-
456 _nb_columns = w.ws_col;
-
-
-
-
-
-
-
-
-
-
-
-
-
477 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
-
-
481 std::string _depth_mark;
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
361 std::vector<int> codes; codes.reserve(3);
+
362 if(this->
fore != fg::none) { codes.push_back(
static_cast<int>(this->
fore ));}
+
363 if(this->
back != bg::none) { codes.push_back(
static_cast<int>(this->
back ));}
+
364 if(this->
style != typo::none) { codes.push_back(
static_cast<int>(this->
style));}
+
365 if(codes.size() == 0) {
return os;}
+
+
+
368 assert(codes.size() > 0);
+
+
370 for(
size_t i=1; i < codes.size(); ++i) {
+
371 os <<
";" << codes[i];
+
+
+
+
+
+
+
+
+
+
+
+
+
+
406 std::ostringstream os;
+
+
408 fmt reset(fmt::typo::reset);
+
+
+
+
+
+
+
+
+
423 void operator=(
clutchlog const&) =
delete;
+
+
+
+
+
+
+
430 {level::critical,
"Critical"},
+
431 {level::error ,
"Error"},
+
432 {level::warning ,
"Warning"},
+
433 {level::progress,
"Progress"},
+
434 {level::note ,
"Note"},
+
435 {level::info ,
"Info"},
+
436 {level::debug ,
"Debug"},
+
437 {level::xdebug ,
"XDebug"}
+
+
+
440 {level::critical,fmt(fmt::fg::red, fmt::typo::underline)},
+
441 {level::error ,fmt(fmt::fg::red, fmt::typo::bold)},
+
442 {level::warning ,fmt(fmt::fg::magenta, fmt::typo::bold)},
+
443 {level::progress,fmt()},
+
444 {level::note ,fmt()},
+
445 {level::info ,fmt()},
+
446 {level::debug ,fmt()},
+
447 {level::xdebug ,fmt()}
+
+
+
+
451 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
+
+
453 _hfill_fmt(fmt::fg::none),
+
+
+
+
457 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
458 _depth(std::numeric_limits<size_t>::max() -
_strip_calls),
+
+
+
+
+
+
+
+
+
+
+
+
470 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
+
+
472 ioctl(STDERR_FILENO, TIOCGWINSZ, &w);
+
+
+
+
+
+
+
+
+
+
+
+
490 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
-
492 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
-
494 static const size_t _max_buffer = 4096;
-
-
-
497 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
+
+
+
496 unsigned short _hfill_max;
+
-
-
+
+
500 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
-
-
-
-
-
-
-
-
-
-
-
523 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
524 void depth(
size_t d) {_depth = d;}
-
527 size_t depth()
const {
return _depth;}
-
-
530 void depth_mark(
const std::string mark) {_depth_mark = mark;}
-
532 std::string depth_mark()
const {
return _depth_mark;}
-
-
534 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
-
535 void hfill_mark(
const char mark) {
_hfill_char = mark;}
-
-
+
+
504 std::string _depth_mark;
+
+
+
+
+
+
+
+
515 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
+
517 static const size_t _max_buffer = 4096;
+
+
+
520 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
558 return ilevel->second;
-
-
560 throw std::out_of_range(
"'" + name +
"' is not a valid log level name");
-
-
-
-
-
-
-
-
-
573 const std::string& in_file,
-
574 const std::string& in_function=
".*",
-
575 const std::string& in_line=
".*"
-
-
-
-
-
-
+
+
+
+
546 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
547 void depth(
size_t d) {_depth = d;}
+
550 size_t depth()
const {
return _depth;}
+
+
553 void depth_mark(
const std::string mark) {_depth_mark = mark;}
+
555 std::string depth_mark()
const {
return _depth_mark;}
+
+
+
+
+
562 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
+
563 void hfill_mark(
const char mark) {_hfill_char = mark;}
+
566 char hfill_mark()
const {
return _hfill_char;}
+
568 void hfill_style(fmt
style) {_hfill_fmt =
style;}
+
573 template<
class ... FMT>
+
574 void style(FMT... styles) { this->hfill_style(fmt(styles...)); }
+
576 fmt hfill_style()
const {
return _hfill_fmt;}
+
578 void hfill_max(
const size_t nmax) {_hfill_max = nmax;}
+
580 unsigned short hfill_max() {
return _hfill_max;}
+
-
587 template<
class ... FMT>
-
-
-
-
-
-
-
-
-
-
607 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
600 return ilevel->second;
+
+
602 throw std::out_of_range(
"'" + name +
"' is not a valid log level name");
+
+
+
+
+
+
+
+
+
615 const std::string& in_file,
+
616 const std::string& in_function=
".*",
+
617 const std::string& in_line=
".*"
+
+
+
+
+
+
-
-
-
628 const std::string&
file,
-
629 const std::string&
func,
-
-
-
-
-
-
-
-
-
638 if(not (scope.stage <=
_stage)) {
-
-
-
-
-
643 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
-
-
-
647 void *buffer[_max_buffer];
-
648 stack_depth = backtrace(buffer, _max_buffer);
-
649 scope.depth = stack_depth;
-
-
-
-
-
-
-
-
-
658 std::ostringstream sline; sline <<
line;
-
-
-
-
662 and std::regex_search(sline.str(),
_in_line);
-
-
-
665 scope.matches = scope.there;
+
629 template<
class ... FMT>
+
+
+
+
+
+
+
+
+
+
649 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
678 const std::string& form,
-
679 const std::string& mark,
-
680 const std::string& tag
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
737 const std::regex re(mark);
-
738 return std::regex_replace(form, re, tag);
-
-
-
-
743 const std::string& form,
-
744 const std::string& mark,
-
-
-
-
748 std::ostringstream stag; stag << tag;
-
749 return replace(form, mark, stag.str());
-
-
-
-
-
755 const std::string& what,
-
-
757 const std::string& name,
-
-
-
760 const std::string&
file,
-
761 const std::string&
func,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
775 std::string letter(1,
_level_word.at(stage).at(0));
-
-
-
778 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
-
-
-
782 std::ostringstream chevrons;
-
-
784 chevrons << _depth_mark;
-
-
-
-
788 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
-
789 const std::string hfill_tag =
"{hfill}";
-
790 const size_t hfill_pos =
format.find(hfill_tag);
-
791 if(hfill_pos != std::string::npos) {
-
792 if(_nb_columns > 0) {
-
793 const size_t left_len = hfill_pos;
-
794 const size_t right_len =
format.size() - hfill_pos - hfill_tag.size();
-
795 if(right_len+left_len > _nb_columns) {
-
-
797 const std::string hfill(std::max((
size_t)0, _nb_columns-right_len),
_hfill_char);
-
-
-
-
801 const std::string hfill(std::max((
size_t)0, _nb_columns - (right_len+left_len)),
_hfill_char);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
816 const std::string& what,
-
817 const std::string&
file,
const std::string&
func,
size_t line
-
-
-
-
-
-
823 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
841 const In container_begin,
const In container_end,
-
842 const std::string&
file,
const std::string&
func,
size_t line,
-
843 const std::string& filename_template =
"dump_{n}.dat",
-
-
-
-
-
-
-
850 const std::string tag =
"\\{n\\}";
-
851 const std::regex re(tag);
-
852 std::string outfile =
"";
-
-
-
855 if(std::regex_search(filename_template, re)) {
-
-
-
-
859 outfile =
replace(filename_template, tag, n);
-
-
861 }
while( fs::exists( outfile ) );
-
-
-
-
865 outfile = filename_template;
-
+
+
+
670 const std::string&
file,
+
671 const std::string&
func,
+
+
+
+
+
+
+
+
+
680 if(not (scope.stage <=
_stage)) {
+
+
+
+
+
685 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
+
+
+
689 void *buffer[_max_buffer];
+
690 stack_depth = backtrace(buffer, _max_buffer);
+
691 scope.depth = stack_depth;
+
+
+
+
+
+
+
+
+
700 std::ostringstream sline; sline <<
line;
+
+
+
+
704 and std::regex_search(sline.str(),
_in_line);
+
+
+
707 scope.matches = scope.there;
+
+
+
+
+
+
720 const std::string& form,
+
721 const std::string& mark,
+
722 const std::string& tag
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
779 const std::regex re(mark);
+
780 return std::regex_replace(form, re, tag);
+
+
+
+
785 const std::string& form,
+
786 const std::string& mark,
+
+
+
+
790 std::ostringstream stag; stag << tag;
+
791 return replace(form, mark, stag.str());
+
+
+
+
+
797 const std::string& what,
+
+
799 const std::string& name,
+
+
+
802 const std::string&
file,
+
803 const std::string&
func,
+
+
+
+
+
+
+
+
+
+
+
+
+
+
817 std::string letter(1,
_level_word.at(stage).at(0));
+
+
+
820 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
+
+
+
824 std::ostringstream chevrons;
+
+
826 chevrons << _depth_mark;
+
+
+
+
830 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL
+
831 const std::string hfill_tag =
"{hfill}";
+
832 const size_t hfill_pos =
format.find(hfill_tag);
+
833 if(hfill_pos != std::string::npos) {
+
834 if(_nb_columns > 0) {
+
835 const size_t left_len = hfill_pos;
+
836 const size_t right_len =
format.size() - hfill_pos - hfill_tag.size();
+
837 if(right_len+left_len > _nb_columns) {
+
+
839 const std::string hfill(std::max((
size_t)0, _nb_columns-right_len), _hfill_char);
+
840 const std::string hfill_styled = _hfill_fmt(hfill);
+
+
+
+
844 const std::string hfill(std::max((
size_t)0, _nb_columns - (right_len+left_len)), _hfill_char);
+
845 const std::string hfill_styled = _hfill_fmt(hfill);
+
+
+
+
+
850 const std::string hfill(1, _hfill_char);
+
851 const std::string hfill_styled = _hfill_fmt(hfill);
+
+
+
+
+
+
+
+
+
+
862 const std::string& what,
+
863 const std::string&
file,
const std::string&
func,
size_t line
+
+
+
-
868 std::ofstream fd(outfile);
-
-
-
871 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
-
-
-
-
-
-
-
-
-
+
+
869 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
+
+
+
+
+
+
+
+
+
+
+
-
883 std::copy(container_begin, container_end,
-
884 std::ostream_iterator<typename In::value_type>(fd, sep.c_str()));
-
-
-
-
-
-
-
-
895 #else // not WITH_CLUTCHLOG
-
-
-
-
-
-
-
-
-
904 #pragma GCC diagnostic push
-
905 #pragma GCC diagnostic ignored "-Wreturn-type"
-
-
-
-
-
910 enum level {critical=0, error=1, warning=2, progress=3, note=4, info=5, debug=6, xdebug=7};
-
-
-
913 enum class fg { black, red, green, yellow, blue, magenta, cyan, white, none }
fore;
-
914 enum class bg { black, red, green, yellow, blue, magenta, cyan, white, none }
back;
-
915 enum class typo { reset, bold, underline, inverse, none }
style;
-
-
-
-
-
-
-
-
-
924 std::ostream&
print_on(std::ostream&)
const {}
-
-
926 friend std::ostream&
operator<<(std::ostream&,
const fmt&) {}
-
927 std::string
operator()(
const std::string&)
const {}
-
-
-
-
931 void operator=(
clutchlog const&) =
delete;
-
-
-
-
-
-
-
-
-
-
-
-
-
944 void format(
const std::string&) {}
-
945 std::string
format()
const {}
-
-
-
-
-
950 void out(std::ostream&) {}
-
951 std::ostream&
out() {}
-
-
953 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
-
954 void depth(
size_t) {}
-
955 size_t depth()
const {}
-
-
957 void depth_mark(
const std::string) {}
-
958 std::string depth_mark()
const {}
-
-
960 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
-
961 void hfill_mark(
const char) {}
-
962 char hfill_mark()
const {}
-
-
-
-
-
-
968 const std::map<std::string,level>
levels()
const {};
-
-
-
971 void file(std::string) {}
-
972 void func(std::string) {}
-
973 void line(std::string) {}
-
-
975 #pragma GCC diagnostic push
-
976 #pragma GCC diagnostic ignored "-Wunused-parameter"
-
-
-
979 const std::string& in_function=
".*",
-
980 const std::string& in_line=
".*"
-
-
-
983 #pragma GCC diagnostic pop
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
1021 const std::string&,
const std::string&,
size_t
-
-
-
-
-
-
-
-
1029 const std::string&,
const std::string&,
size_t,
+
+
+
+
887 const In container_begin,
const In container_end,
+
888 const std::string&
file,
const std::string&
func,
size_t line,
+
889 const std::string& filename_template =
"dump_{n}.dat",
+
+
+
+
+
+
+
896 const std::string tag =
"\\{n\\}";
+
897 const std::regex re(tag);
+
898 std::string outfile =
"";
+
+
+
901 if(std::regex_search(filename_template, re)) {
+
+
+
+
905 outfile =
replace(filename_template, tag, n);
+
+
907 }
while( fs::exists( outfile ) );
+
+
+
+
911 outfile = filename_template;
+
+
+
914 std::ofstream fd(outfile);
+
+
+
917 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
+
+
+
+
+
+
+
+
+
+
+
929 std::copy(container_begin, container_end,
+
930 std::ostream_iterator<typename In::value_type>(fd, sep.c_str()));
+
+
+
+
+
+
+
+
941 #else // not WITH_CLUTCHLOG
+
+
+
+
+
+
+
+
+
950 #pragma GCC diagnostic push
+
951 #pragma GCC diagnostic ignored "-Wreturn-type"
+
+
+
+
+
956 enum level {critical=0, error=1, warning=2, progress=3, note=4, info=5, debug=6, xdebug=7};
+
+
+
959 enum class fg { black, red, green, yellow, blue, magenta, cyan, white, none }
fore;
+
960 enum class bg { black, red, green, yellow, blue, magenta, cyan, white, none }
back;
+
961 enum class typo { reset, bold, underline, inverse, none }
style;
+
+
+
+
+
+
+
+
+
970 std::ostream&
print_on(std::ostream&)
const {}
+
+
972 friend std::ostream&
operator<<(std::ostream&,
const fmt&) {}
+
973 std::string
operator()(
const std::string&)
const {}
+
+
+
+
977 void operator=(
clutchlog const&) =
delete;
+
+
+
+
+
+
+
+
+
+
+
+
+
990 void format(
const std::string&) {}
+
991 std::string
format()
const {}
+
+
+
+
+
996 void out(std::ostream&) {}
+
997 std::ostream&
out() {}
+
+
999 #if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
+
1000 void depth(
size_t) {}
+
1001 size_t depth()
const {}
+
+
1003 void depth_mark(
const std::string) {}
+
1004 std::string depth_mark()
const {}
+
1005 void strip_calls(
const size_t) {}
+
1006 size_t strip_calls()
const {}
+
+
1008 #if CLUTCHLOG_HAVE_UNIX_SYSIOCTL == 1
+
1009 void hfill_mark(
const char) {}
+
1010 char hfill_mark()
const {}
+
1011 void hfill_fmt(fmt) {}
+
1012 fmt hfill_fmt()
const {}
+
1013 void hfill_max(
const size_t) {}
+
1014 unsigned short hfill_max() {}
+
+
+
+
+
+
1020 const std::map<std::string,level>
levels()
const {}
+
+
+
1023 void file(std::string) {}
+
1024 void func(std::string) {}
+
1025 void line(std::string) {}
+
+
1027 #pragma GCC diagnostic push
+
1028 #pragma GCC diagnostic ignored "-Wunused-parameter"
+
-
-
-
-
+
1031 const std::string& in_function=
".*",
+
1032 const std::string& in_line=
".*"
+
+
1035 #pragma GCC diagnostic pop
-
1036 #endif // WITH_CLUTCHLOG
-
-
1038 #endif // __CLUTCHLOG_H__
+
1036 template<
class ... FMT>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
1075 const std::string&,
const std::string&,
size_t
+
+
+
+
+
+
+
+
1083 const std::string&,
const std::string&,
size_t,
+
+
+
+
+
+
1089 #pragma GCC diagnostic pop
+
1090 #endif // WITH_CLUTCHLOG
+
+
1092 #endif // CLUTCHLOG_H
-
void file(std::string file)
Set the regular expression filtering the file location.
Definition: clutchlog.h:565
+
void file(std::string file)
Set the regular expression filtering the file location.
Definition: clutchlog.h:607
#define CLUTCHDUMP_DEFAULT_FORMAT
Compile-time default format of the comment line in file dump.
Definition: clutchlog.h:217
-
fg
Foreground color codes.
Definition: clutchlog.h:297
+
fg
Foreground color codes.
Definition: clutchlog.h:310
static std::string dump_default_format
Default format of the comment line in file dump.
Definition: clutchlog.h:231
-
const std::map< std::string, level > & levels() const
Get the map of available log levels string representations toward their identifier....
Definition: clutchlog.h:548
-
void out(std::ostream &out)
Set the output stream on which to print.
Definition: clutchlog.h:519
-
fmt()
 Empty constructor, only useful for a no-op formatter.
Definition: clutchlog.h:332
-
static clutchlog & logger()
Get the logger instance.
Definition: clutchlog.h:273
-
void line(std::string line)
Set the regular expression filtering the line location.
Definition: clutchlog.h:569
-
void format_comment(const std::string &format)
Set the template string for dumps.
Definition: clutchlog.h:514
-
typo
Typographic style codes.
Definition: clutchlog.h:323
+
const std::map< std::string, level > & levels() const
Get the map of available log levels string representations toward their identifier....
Definition: clutchlog.h:590
+
void out(std::ostream &out)
Set the output stream on which to print.
Definition: clutchlog.h:542
+
fmt()
 Empty constructor, only useful for a no-op formatter.
Definition: clutchlog.h:345
+
static clutchlog & logger()
Get the logger instance.
Definition: clutchlog.h:286
+
void line(std::string line)
Set the regular expression filtering the line location.
Definition: clutchlog.h:611
+
void format_comment(const std::string &format)
Set the template string for dumps.
Definition: clutchlog.h:537
+
typo
Typographic style codes.
Definition: clutchlog.h:336
#define CLUTCHDUMP_DEFAULT_SEP
Compile-time default item separator for dump.
Definition: clutchlog.h:235
#define CLUTCHLOG_HFILL_MARK
Character used as a filling for right-align the right part of messages with "{hfill}".
Definition: clutchlog.h:256
static std::string default_depth_mark
Default mark for stack depth.
Definition: clutchlog.h:245
#define CLUTCHLOG_DEFAULT_FORMAT
Compile-time default format of the messages (debug mode: with absolute location).
Definition: clutchlog.h:194
-
std::string format() const
Get the template string.
Definition: clutchlog.h:511
-
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:814
-
level level_of(const std::string name)
Return the log level tag corresponding to the given pre-configured name.
Definition: clutchlog.h:554
-
std::string _format_dump
Current format of the file output.
Definition: clutchlog.h:472
-
std::string operator()(const std::string &msg) const
Format the given string with the currently encoded format.
Definition: clutchlog.h:391
-
std::string format(std::string format, 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:753
-
std::string _format_log
Current format of the standard output.
Definition: clutchlog.h:470
-
level
Available log levels.
Definition: clutchlog.h:280
-
level stage
Current log level.
Definition: clutchlog.h:606
+
std::string format() const
Get the template string.
Definition: clutchlog.h:534
+
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:860
+
level level_of(const std::string name)
Return the log level tag corresponding to the given pre-configured name.
Definition: clutchlog.h:596
+
static unsigned short default_hfill_max
Default maximum number of character used as a filling for right-align the right part of messages with...
Definition: clutchlog.h:268
+
std::string _format_dump
Current format of the file output.
Definition: clutchlog.h:489
+
std::string operator()(const std::string &msg) const
Format the given string with the currently encoded format.
Definition: clutchlog.h:404
+
std::string format(std::string format, 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:795
+
std::string _format_log
Current format of the standard output.
Definition: clutchlog.h:487
+
level
Available log levels.
Definition: clutchlog.h:293
+
level stage
Current log level.
Definition: clutchlog.h:648
#define CLUTCHLOG_DEFAULT_DEPTH_MARK
Compile-time default mark for stack depth.
Definition: clutchlog.h:242
-
friend std::ostream & operator<<(std::ostream &os, const fmt &fmt)
Output stream overload.
Definition: clutchlog.h:376
-
std::map< level, fmt > _level_fmt
Dictionary of level identifier to their format.
Definition: clutchlog.h:468
-
std::regex _in_line
Current line location filter.
Definition: clutchlog.h:490
+
friend std::ostream & operator<<(std::ostream &os, const fmt &fmt)
Output stream overload.
Definition: clutchlog.h:389
+
std::map< level, fmt > _level_fmt
Dictionary of level identifier to their format.
Definition: clutchlog.h:485
+
std::regex _in_line
Current line location filter.
Definition: clutchlog.h:513
enum clutchlog::fmt::typo style
Typographic style.
-
level _stage
Current log level.
Definition: clutchlog.h:484
-
const size_t _strip_calls
Current number of call stack levels to remove from depth display.
Definition: clutchlog.h:462
-
std::string format_comment() const
Get the template string for dumps.
Definition: clutchlog.h:516
+
level _stage
Current log level.
Definition: clutchlog.h:507
+
std::string format_comment() const
Get the template string for dumps.
Definition: clutchlog.h:539
+
size_t _strip_calls
Current number of call stack levels to remove from depth display.
Definition: clutchlog.h:479
#define CLUTCHLOG_STRIP_CALLS
Compile-time number of call stack levels to remove from depth display by default.
Definition: clutchlog.h:249
-
std::ostream * _out
Standard output.
Definition: clutchlog.h:476
-
void func(std::string func)
Set the regular expression filtering the function location.
Definition: clutchlog.h:567
-
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:572
+
std::ostream * _out
Standard output.
Definition: clutchlog.h:499
+
void func(std::string func)
Set the regular expression filtering the function location.
Definition: clutchlog.h:609
+
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:614
static char default_hfill_char
Default character used as a filling for right-align the right part of messages with "{hfill}".
Definition: clutchlog.h:259
-
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:839
-
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:742
-
Color and style formatter for ANSI terminal escape sequences.
Definition: clutchlog.h:294
-
std::regex _in_file
Current file location filter.
Definition: clutchlog.h:486
-
std::ostream & out()
Get the output stream on which to print.
Definition: clutchlog.h:521
-
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:677
+
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:885
+
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:784
+
Color and style formatter for ANSI terminal escape sequences.
Definition: clutchlog.h:307
+
std::regex _in_file
Current file location filter.
Definition: clutchlog.h:509
+
std::ostream & out()
Get the output stream on which to print.
Definition: clutchlog.h:544
+
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:719
static unsigned int default_strip_calls
Number of call stack levels to remove from depth display by default.
Definition: clutchlog.h:252
-
char _hfill_char
Character for filling.
Definition: clutchlog.h:474
static std::string default_format
Default format of the messages.
Definition: clutchlog.h:209
enum clutchlog::fmt::fg fore
Foreground color.
-
void threshold(const std::string &l)
Set the log level (below which logs are not printed) with a string.
Definition: clutchlog.h:544
-
bool there
Location is compatible.
Definition: clutchlog.h:612
-
Structure holding a location matching.
Definition: clutchlog.h:602
-
std::regex _in_func
Current function location filter.
Definition: clutchlog.h:488
-
void threshold(level l)
Set the log level (below which logs are not printed) with an identifier.
Definition: clutchlog.h:542
-
void style(level stage, fmt style)
Set the style (color and typo) of the given log level, passing a fmt instance.
Definition: clutchlog.h:590
-
const std::map< level, std::string > _level_word
Dictionary of level identifier to their string representation.
Definition: clutchlog.h:464
-
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:626
-
bool matches
Everything is compatible.
Definition: clutchlog.h:604
+
void threshold(const std::string &l)
Set the log level (below which logs are not printed) with a string.
Definition: clutchlog.h:586
+
bool there
Location is compatible.
Definition: clutchlog.h:654
+
Structure holding a location matching.
Definition: clutchlog.h:644
+
std::regex _in_func
Current function location filter.
Definition: clutchlog.h:511
+
void threshold(level l)
Set the log level (below which logs are not printed) with an identifier.
Definition: clutchlog.h:584
+
void style(level stage, fmt style)
Set the style (color and typo) of the given log level, passing a fmt instance.
Definition: clutchlog.h:632
+
const std::map< level, std::string > _level_word
Dictionary of level identifier to their string representation.
Definition: clutchlog.h:481
+
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:668
+
bool matches
Everything is compatible.
Definition: clutchlog.h:646
static std::string dump_default_sep
Default item separator for dump.
Definition: clutchlog.h:238
-
level threshold() const
Get the log level below which logs are not printed.
Definition: clutchlog.h:546
-
std::ostream & print_on(std::ostream &os) const
Print the currently encoded format escape code on the given output stream.
Definition: clutchlog.h:346
-
std::map< std::string, level > _word_level
Dictionary of level string to their identifier.
Definition: clutchlog.h:466
-
void style(level stage, FMT... styles)
Set the style (color and typo) of the given log level.
Definition: clutchlog.h:588
-
scope_t()
Constructor.
Definition: clutchlog.h:614
+
level threshold() const
Get the log level below which logs are not printed.
Definition: clutchlog.h:588
+
std::ostream & print_on(std::ostream &os) const
Print the currently encoded format escape code on the given output stream.
Definition: clutchlog.h:359
+
std::map< std::string, level > _word_level
Dictionary of level string to their identifier.
Definition: clutchlog.h:483
+
void style(level stage, FMT... styles)
Set the style (color and typo) of the given log level.
Definition: clutchlog.h:630
+
scope_t()
Constructor.
Definition: clutchlog.h:656
#define CLUTCHLOG_HAVE_UNIX_SYSINFO
POSIX headers necessary for stack depth management are available.
Definition: clutchlog.h:32
Definition: clutchlog.h:175
-
fmt style(level stage) const
Get the configured fmt instance of the given log level.
Definition: clutchlog.h:592
-
bg
Background color codes.
Definition: clutchlog.h:310
+
fmt style(level stage) const
Get the configured fmt instance of the given log level.
Definition: clutchlog.h:634
+
bg
Background color codes.
Definition: clutchlog.h:323
enum clutchlog::fmt::bg back
Background color.