From: guido Date: Tue, 11 Jan 2000 04:35:48 +0000 (+0000) Subject: prepare for time log X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64f226463c24748bfbb9cae3ef7401d913f54151;p=dealii-svn.git prepare for time log git-svn-id: https://svn.dealii.org/trunk@2185 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/logstream.h b/deal.II/base/include/base/logstream.h index 14cc58019f..c9d04b6c5d 100644 --- a/deal.II/base/include/base/logstream.h +++ b/deal.II/base/include/base/logstream.h @@ -93,7 +93,11 @@ class LogStream * prefixes for output to a file. */ unsigned int file_depth; - + + /** + * Flag for printing execution time. + */ + bool print_utime; public: /** * Standard constructor, since we @@ -157,6 +161,14 @@ class LogStream */ void depth_file (unsigned int n); + /** + * Set time printing flag. If this flag + * is true, each output line will + * be prepended by the user time used + * by the running program so far. + */ + void log_execution_time(bool flag); + /** * Output a constant something through * this stream. @@ -187,6 +199,13 @@ class LogStream * Declare this function as a friend. */ friend void endl (LogStream &); +private: + /** + * Print head of line. This prints + * optional time information and + * the contents of the prefix stack. + */ + void print_line_head(); }; @@ -209,7 +228,12 @@ LogStream::push (const string& text) prefixes.push(pre); } - +inline +void +LogStream::log_execution_time(bool flag) +{ + print_utime = flag; +} // sorry for the weird following declaration spanning 5 lines, but // doc++ gets confused if we be more compact :-( @@ -225,12 +249,7 @@ operator<< (const T& t) // and a colon if (was_endl) { - if (prefixes.size() <= std_depth) - *std_out << prefixes.top() << ':'; - - if (file && (prefixes.size() <= file_depth)) - *file << prefixes.top() << ':'; - + print_line_head(); was_endl = false; }; diff --git a/deal.II/base/source/log.cc b/deal.II/base/source/log.cc index 02d70e7213..a19c11dc23 100644 --- a/deal.II/base/source/log.cc +++ b/deal.II/base/source/log.cc @@ -3,7 +3,7 @@ #include #include - +#include LogStream deallog; @@ -11,7 +11,8 @@ LogStream deallog; LogStream::LogStream() : std_out(&cerr), file(0), was_endl(true), - std_depth(10000), file_depth(10000) + std_depth(10000), file_depth(10000), + print_utime(false) { prefixes.push("DEAL:"); } @@ -31,29 +32,42 @@ LogStream::attach(ostream& o) void LogStream::detach () { file = 0; -}; +} -void LogStream::pop () +void +LogStream::pop () { prefixes.pop(); -}; +} -void LogStream::depth_console(unsigned n) +void +LogStream::depth_console(unsigned n) { std_depth = n; -}; +} -void LogStream::depth_file(unsigned n) +void +LogStream::depth_file(unsigned n) { file_depth = n; -}; +} + + +void +LogStream::print_line_head() +{ + if (prefixes.size() <= std_depth) + *std_out << prefixes.top() << ':'; + if (file && (prefixes.size() <= file_depth)) + *file << prefixes.top() << ':'; +} LogStream&