indentlog: refactor: use color_spec in code_location_impl<> inserter
This commit is contained in:
parent
92c74b90a0
commit
a51355417a
3 changed files with 6 additions and 11 deletions
|
|
@ -19,13 +19,12 @@ namespace xo {
|
|||
public:
|
||||
code_location_impl(std::string_view file,
|
||||
std::uint32_t line,
|
||||
color_encoding encoding = CE_Ansi,
|
||||
std::uint32_t color = 31 /*red*/)
|
||||
: file_{file}, line_{line}, encoding_{encoding}, color_{color} {}
|
||||
color_spec colorspec)
|
||||
: file_{file}, line_{line}, color_spec_{colorspec} {}
|
||||
|
||||
void print_code_location(std::ostream & os) const {
|
||||
os << "["
|
||||
<< with_color(color_spec(encoding_, color_), basename(file_))
|
||||
<< with_color(color_spec_, basename(file_))
|
||||
<< ":"
|
||||
<< line_
|
||||
<< "]";
|
||||
|
|
@ -36,10 +35,8 @@ namespace xo {
|
|||
std::string_view file_;
|
||||
/* __LINE__ */
|
||||
std::uint32_t line_ = 0;
|
||||
/* color encoding for file,line */
|
||||
color_encoding encoding_ = CE_Ansi;
|
||||
/* color for file,line */
|
||||
std::uint32_t color_ = 0;
|
||||
/* color encoding for [file:line] */
|
||||
color_spec color_spec_;
|
||||
}; /*code_location_impl*/
|
||||
|
||||
using code_location = code_location_impl<class code_location_impl_tag>;
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ namespace xo {
|
|||
|
||||
function_style style() const { return style_; }
|
||||
color_spec const & colorspec() const { return color_spec_; }
|
||||
//color_encoding encoding() const { return color_spec_.encoding(); }
|
||||
//std::uint32_t color() const { return color_spec_.code(); }
|
||||
std::string_view const & pretty() const { return pretty_; }
|
||||
|
||||
/* e.g.
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ namespace xo {
|
|||
|
||||
std::stringstream ss;
|
||||
ss << code_location(this->file_, this->line_,
|
||||
log_config::encoding, log_config::code_location_color);
|
||||
color_spec(log_config::encoding, log_config::code_location_color));
|
||||
|
||||
std::string ss_str = std::move(ss.str()); /*c++20*/
|
||||
sbuf2->sputn(ss_str.c_str(), ss_str.size());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue