diff --git a/README.md b/README.md index d8a866d..a011415 100644 --- a/README.md +++ b/README.md @@ -412,6 +412,10 @@ For example: 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 ============== diff --git a/clutchlog/clutchlog.h b/clutchlog/clutchlog.h index c79e0e9..b5a09ef 100644 --- a/clutchlog/clutchlog.h +++ b/clutchlog/clutchlog.h @@ -1288,17 +1288,25 @@ class clutchlog row = replace(row, "\\{name\\}", name); row = replace(row, "\\{depth\\}", actual_depth); - std::ostringstream chevrons; - for(size_t i = _strip_calls; i < depth; ++i) { - chevrons << _depth_mark; - } - row = replace(row, "\\{depth_marks\\}", chevrons.str()); - if(_depth_fmts.size() == 0) { row = replace(row, "\\{depth_fmt\\}", fmt(actual_depth % 256).str() ); + + std::ostringstream chevrons; + for(size_t i = 0; i < actual_depth; ++i) { + chevrons << _depth_mark; + } + row = replace(row, "\\{depth_marks\\}", chevrons.str()); + } else { row = replace(row, "\\{depth_fmt\\}", _depth_fmts[std::min(actual_depth,_depth_fmts.size()-1)].str() ); + + std::ostringstream chevrons; + for(size_t i = 0; i < actual_depth; ++i) { + chevrons << _depth_fmts[std::min(i+1,_depth_fmts.size()-1)].str() + << _depth_mark; + } + row = replace(row, "\\{depth_marks\\}", chevrons.str()); } #endif row = replace(row, "\\{level_fmt\\}", _level_fmt.at(stage).str()); diff --git a/tests/t-demo-extravagant.cpp b/tests/t-demo-extravagant.cpp index 3637924..a7ed491 100644 --- a/tests/t-demo-extravagant.cpp +++ b/tests/t-demo-extravagant.cpp @@ -83,21 +83,29 @@ int main(const int argc, char* argv[]) log.hfill_mark('-'); const short dark = 238; - const short lite = 250; + const short lite = 245; + + std::vector greys = {fmt(15)}; + for(unsigned short i=255; i>231; i-=3) { + greys.push_back( fmt(i) ); + } + log.depth_styles(greys); format << fmt(dark,lite) << "{name}" - << fmt(lite,dark) << "" - << fmt(fg::none,dark) << "{level_fmt}" << " {level_short} " << reset - << fmt(dark,bg::none) << "" << reset - << fmt(dark,bg::none) << "{depth_marks}" << reset + << fmt(fg::none,lite,typo::inverse) << "{level_fmt}" + << fmt(fg::none,bg::black,typo::inverse) << "{level_fmt}" << " {level_short} " << reset + << "{level_fmt} " << reset + << fmt(dark,bg::none) << "{depth_marks}" //<< reset << "{level_fmt}" + // << "{funchash_fmt}" << bold("{msg}") - << discreet(" {hfill} ") + // << discreet(" {hfill} ") + << "{depth_fmt} {hfill} " << fmt(dark,bg::none) << "" - << fmt(fg::none,dark) << "{level_fmt} {func} " + << fmt(fg::none,dark) << "{funchash_fmt}{func} " << fmt(lite,dark) << "" - << fmt(dark,lite) << "{file}" << reset + << fmt(dark,lite) << "{filehash_fmt}{file}" << reset << fmt(dark,lite) << "" << fmt(lite,dark) << "{line}" << reset << "\n"; diff --git a/tests/t-hash-color.cpp b/tests/t-hash-color.cpp index 1c6882f..68b1c08 100644 --- a/tests/t-hash-color.cpp +++ b/tests/t-hash-color.cpp @@ -34,7 +34,7 @@ int main(/*const int argc, char* argv[]*/) fmt reset(typo::reset); std::ostringstream tpl; - tpl << "{level_fmt}Having a {level} {filehash_fmt}within {file} {funchash_fmt}calling {func} {depth_fmt}at level {depth}" + tpl << "{level_fmt}Having a {level} {filehash_fmt}within {file} {funchash_fmt}calling {func} {depth_fmt}at depth {depth_marks} {depth} " << reset << " : {msg}\n"; log.format(tpl.str()); log.threshold(clutchlog::level::xdebug);