feat(depth_marks): atomic styling of depth marks
Color each `{depth_marks}` with the corresponding `depth_styles`.
Implements #8
This commit is contained in:
parent
286ab85aaa
commit
0b970fc2ee
4 changed files with 35 additions and 15 deletions
|
|
@ -412,6 +412,10 @@ For example:
|
||||||
log.depth_styles({ fmt(255), fmt(250), fmt(245), fmt(240), fmt(235) });
|
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
|
Advanced Usage
|
||||||
==============
|
==============
|
||||||
|
|
|
||||||
|
|
@ -1288,17 +1288,25 @@ class clutchlog
|
||||||
row = replace(row, "\\{name\\}", name);
|
row = replace(row, "\\{name\\}", name);
|
||||||
row = replace(row, "\\{depth\\}", actual_depth);
|
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) {
|
if(_depth_fmts.size() == 0) {
|
||||||
row = replace(row, "\\{depth_fmt\\}", fmt(actual_depth % 256).str() );
|
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 {
|
} else {
|
||||||
row = replace(row, "\\{depth_fmt\\}",
|
row = replace(row, "\\{depth_fmt\\}",
|
||||||
_depth_fmts[std::min(actual_depth,_depth_fmts.size()-1)].str() );
|
_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
|
#endif
|
||||||
row = replace(row, "\\{level_fmt\\}", _level_fmt.at(stage).str());
|
row = replace(row, "\\{level_fmt\\}", _level_fmt.at(stage).str());
|
||||||
|
|
|
||||||
|
|
@ -83,21 +83,29 @@ int main(const int argc, char* argv[])
|
||||||
log.hfill_mark('-');
|
log.hfill_mark('-');
|
||||||
|
|
||||||
const short dark = 238;
|
const short dark = 238;
|
||||||
const short lite = 250;
|
const short lite = 245;
|
||||||
|
|
||||||
|
std::vector<clutchlog::fmt> greys = {fmt(15)};
|
||||||
|
for(unsigned short i=255; i>231; i-=3) {
|
||||||
|
greys.push_back( fmt(i) );
|
||||||
|
}
|
||||||
|
log.depth_styles(greys);
|
||||||
|
|
||||||
format
|
format
|
||||||
<< fmt(dark,lite) << "{name}"
|
<< fmt(dark,lite) << "{name}"
|
||||||
<< fmt(lite,dark) << ""
|
<< fmt(fg::none,lite,typo::inverse) << "{level_fmt}"
|
||||||
<< fmt(fg::none,dark) << "{level_fmt}" << " {level_short} " << reset
|
<< fmt(fg::none,bg::black,typo::inverse) << "{level_fmt}" << " {level_short} " << reset
|
||||||
<< fmt(dark,bg::none) << "" << reset
|
<< "{level_fmt} " << reset
|
||||||
<< fmt(dark,bg::none) << "{depth_marks}" << reset
|
<< fmt(dark,bg::none) << "{depth_marks}" //<< reset
|
||||||
<< "{level_fmt}"
|
<< "{level_fmt}"
|
||||||
|
// << "{funchash_fmt}"
|
||||||
<< bold("{msg}")
|
<< bold("{msg}")
|
||||||
<< discreet(" {hfill} ")
|
// << discreet(" {hfill} ")
|
||||||
|
<< "{depth_fmt} {hfill} "
|
||||||
<< fmt(dark,bg::none) << ""
|
<< fmt(dark,bg::none) << ""
|
||||||
<< fmt(fg::none,dark) << "{level_fmt} {func} "
|
<< fmt(fg::none,dark) << "{funchash_fmt}{func} "
|
||||||
<< fmt(lite,dark) << ""
|
<< fmt(lite,dark) << ""
|
||||||
<< fmt(dark,lite) << "{file}" << reset
|
<< fmt(dark,lite) << "{filehash_fmt}{file}" << reset
|
||||||
<< fmt(dark,lite) << ""
|
<< fmt(dark,lite) << ""
|
||||||
<< fmt(lite,dark) << "{line}" << reset
|
<< fmt(lite,dark) << "{line}" << reset
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ int main(/*const int argc, char* argv[]*/)
|
||||||
|
|
||||||
fmt reset(typo::reset);
|
fmt reset(typo::reset);
|
||||||
std::ostringstream tpl;
|
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";
|
<< reset << " : {msg}\n";
|
||||||
log.format(tpl.str());
|
log.format(tpl.str());
|
||||||
log.threshold(clutchlog::level::xdebug);
|
log.threshold(clutchlog::level::xdebug);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue