Commit 4583a71d authored by Marco Amagliani's avatar Marco Amagliani
Browse files

Allow enable / disable the console output.

parent 6dbd2a4c
...@@ -115,7 +115,7 @@ public: ...@@ -115,7 +115,7 @@ public:
print(' ', false); // indents never go onto the console! print(' ', false); // indents never go onto the console!
} }
bffr_.append(&_c, 1); bffr_.append(&_c, 1);
if (_cnsl) if (_cnsl && enbl_cnsl_)
std::cerr << _c; // print on the console std::cerr << _c; // print on the console
if (_c == '\n') if (_c == '\n')
{ {
...@@ -173,6 +173,12 @@ public: ...@@ -173,6 +173,12 @@ public:
double_format_ = str; double_format_ = str;
} }
bool enable_console_output(const bool _enbl)
{
auto prev_val = enbl_cnsl_;
enbl_cnsl_ = _enbl;
return prev_val;
}
void print(double _d) void print(double _d)
{ {
...@@ -387,6 +393,7 @@ private: ...@@ -387,6 +393,7 @@ private:
int num_flush_; int num_flush_;
int priority_; // Last permission granted int priority_; // Last permission granted
bool line_strt_; // are we at the start of th line? bool line_strt_; // are we at the start of th line?
bool enbl_cnsl_ = true; // prints also on cerr
std::string bffr_; std::string bffr_;
std::string output_; std::string output_;
...@@ -429,6 +436,11 @@ void File::set_double_format(const char* const str) ...@@ -429,6 +436,11 @@ void File::set_double_format(const char* const str)
impl_->set_double_format(str); impl_->set_double_format(str);
} }
bool File::enable_console_output(const bool _enbl)
{
return impl_->enable_console_output(_enbl);
}
}//namespace Debug }//namespace Debug
#endif // DEB_ON #endif // DEB_ON
...@@ -43,6 +43,8 @@ public: ...@@ -43,6 +43,8 @@ public:
const char* double_format() const; const char* double_format() const;
void set_double_format(const char* const str); void set_double_format(const char* const str);
bool enable_console_output(const bool _enbl);
private: private:
class Impl; class Impl;
Impl* impl_; Impl* impl_;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment