(re-) added log to std::clog; refs #169

master
Marc Wäckerlin 12 years ago
parent 25d01618f6
commit 7d10b872c9
  1. 12
      src/qbrowserlib/log.cxx
  2. 9
      src/qbrowserlib/log.hxx

@ -21,9 +21,8 @@ namespace qbrowserlib {
if (!_debug || !_close) return; if (!_debug || !_close) return;
++_level; ++_level;
std::stringstream ss; std::stringstream ss;
// init(ss);
indent(ss)<<"\\ "<<_name; indent(ss)<<"\\ "<<_name;
// std::clog<<close(ss).str()<<std::endl; close(init(std::clog)<<ss.str())<<std::endl;
if (!_dialog) _dialog = new LogDialog; if (!_dialog) _dialog = new LogDialog;
_dialog->append(*this, ss.str()); _dialog->append(*this, ss.str());
} }
@ -31,9 +30,8 @@ namespace qbrowserlib {
Log::~Log() throw() { Log::~Log() throw() {
if (!_debug || !_close) return; if (!_debug || !_close) return;
std::stringstream ss; std::stringstream ss;
// init(ss);
indent(ss)<<"/ "<<_name; indent(ss)<<"/ "<<_name;
// std::clog<<close(ss).str()<<std::endl; close(init(std::clog)<<ss.str())<<std::endl;
--_level; --_level;
if (!_dialog) _dialog = new LogDialog; if (!_dialog) _dialog = new LogDialog;
_dialog->append(*this, ss.str()); _dialog->append(*this, ss.str());
@ -47,7 +45,7 @@ namespace qbrowserlib {
_dialog->show(); _dialog->show();
} }
std::stringstream& Log::init(std::stringstream& ss) { std::ostream& Log::init(std::ostream& ss) {
if (_addr) if (_addr)
ss<<std::hex<<std::setw(15)<<_addr<<": "<<std::dec; ss<<std::hex<<std::setw(15)<<_addr<<": "<<std::dec;
else else
@ -55,12 +53,12 @@ namespace qbrowserlib {
return ss; return ss;
} }
std::stringstream& Log::indent(std::stringstream& ss) { std::ostream& Log::indent(std::ostream& ss) {
ss<<std::setw(2+_level)<<std::setfill(' '); ss<<std::setw(2+_level)<<std::setfill(' ');
return ss; return ss;
} }
std::stringstream& Log::close(std::stringstream& ss) { std::ostream& Log::close(std::ostream& ss) {
ss<<" ("<<_file<<':'<<_line<<')'; ss<<" ("<<_file<<':'<<_line<<')';
return ss; return ss;
} }

@ -89,11 +89,11 @@ namespace qbrowserlib {
private: private:
std::stringstream& init(std::stringstream& ss); std::ostream& init(std::ostream& ss);
std::stringstream& indent(std::stringstream& ss); std::ostream& indent(std::ostream& ss);
std::stringstream& close(std::stringstream& ss); std::ostream& close(std::ostream& ss);
private: private:
@ -217,9 +217,8 @@ namespace qbrowserlib {
template<typename TYPE> Log& Log::operator<<(TYPE arg) { template<typename TYPE> Log& Log::operator<<(TYPE arg) {
if (!_debug) return *this; if (!_debug) return *this;
std::stringstream ss; std::stringstream ss;
// init(ss);
indent(ss)<<""<<arg; indent(ss)<<""<<arg;
// std::clog<<close(ss).str()<<std::endl; close(init(std::clog)<<ss.str())<<std::endl;
if (!_dialog) _dialog = new LogDialog; if (!_dialog) _dialog = new LogDialog;
_dialog->append(*this, ss.str()); _dialog->append(*this, ss.str());
return *this; return *this;

Loading…
Cancel
Save