From 89851eabde19adead78529a2a6955d2405937e4a Mon Sep 17 00:00:00 2001 From: hartmann Date: Tue, 18 Jan 2000 10:18:09 +0000 Subject: [PATCH] add functions for getting access to the std_out and the file stream, put some inline functions into log.cc. git-svn-id: https://svn.dealii.org/trunk@2246 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/logstream.h | 39 ++++++++++------------ deal.II/base/source/log.cc | 47 +++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 24 deletions(-) diff --git a/deal.II/base/include/base/logstream.h b/deal.II/base/include/base/logstream.h index c9d04b6c5d..ee191480e5 100644 --- a/deal.II/base/include/base/logstream.h +++ b/deal.II/base/include/base/logstream.h @@ -5,6 +5,8 @@ /*---------------------------- logstream.h ---------------------------*/ +#include + #include #include #include @@ -120,8 +122,16 @@ class LogStream * previously attached to this object. */ void detach(); - + /** + * Gives the default stream (#std_out#). + */ + ostream& get_console(); + + /** + * Gives the file stream. + */ + ostream& get_file_stream(); /** * Push another prefix on the @@ -199,6 +209,12 @@ class LogStream * Declare this function as a friend. */ friend void endl (LogStream &); + + /** + * Exception + */ + DeclException0 (ExcNoFileStreamGiven); + private: /** * Print head of line. This prints @@ -214,27 +230,6 @@ private: /* ----------------------------- Inline functions and templates ---------------- */ -inline -void -LogStream::push (const string& text) -{ - // strange enough: if make this - // function non-inline with - // gcc2.8, we get very strange - // compiler errors... - string pre=prefixes.top(); - pre += text; - pre += string(":"); - 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 :-( diff --git a/deal.II/base/source/log.cc b/deal.II/base/source/log.cc index 05bc76f9f1..2712707bcc 100644 --- a/deal.II/base/source/log.cc +++ b/deal.II/base/source/log.cc @@ -35,12 +35,42 @@ LogStream::attach(ostream& o) void LogStream::detach () { file = 0; +}; + + + +ostream& +LogStream::get_console() +{ + return *std_out; +} + + + +ostream& +LogStream::get_file_stream() +{ + Assert(file, ExcNoFileStreamGiven()); + return *file; } void -LogStream::pop () +LogStream::push (const string& text) +{ + // strange enough: if make this + // function non-inline with + // gcc2.8, we get very strange + // compiler errors... + string pre=prefixes.top(); + pre += text; + pre += string(":"); + prefixes.push(pre); +} + + +void LogStream::pop () { prefixes.pop(); } @@ -51,7 +81,7 @@ void LogStream::depth_console(unsigned n) { std_depth = n; -} +}; @@ -59,9 +89,18 @@ void LogStream::depth_file(unsigned n) { file_depth = n; +}; + + + +void +LogStream::log_execution_time(bool flag) +{ + print_utime = flag; } + void LogStream::print_line_head() { @@ -93,9 +132,13 @@ LogStream::print_line_head() } + LogStream& LogStream::operator << (void (f)(LogStream &)) { f(*this); return *this; } + + + -- 2.39.5